Create a Facebook Messenger chatbot with Claudia.js Bot Builder and AWS Lambda in 7 steps

In a world where connectivity is at the tip of our fingers, we are constantly surrounded by conversational chat interfaces and it has become a part of our daily lives.

Instant messaging is not a new concept, my first encounter was back in 1997, when I used to go to my primary school friend’s home and we would log into her ICQ account. That was over 20 years ago! Since then, Yahoo Messenger, MSN Messenger, SMS, Skype, Viber, Whatsapp, Facebook Messenger, Google Talk and Slack have appeared, just to name a few.

As technology advances, we are constantly developing automated programs to save us time and to help us become more efficient. When we have a question, we want the answers almost instantly. Thankfully, we have google. Time is of the essence and our patience threshold is becoming shorter and shorter. In the last 12–18 months, the notion of artificially intelligent chatbots has steadily increased in popularity amongst technology news and there are more and more AI machine learning programs and third-party tools and domains being integrated and developed. AI chatbots can help with getting faster customer support responses. Is this the way of our future?

As a side project for work, I had fun developing a simple Facebook Messenger chatbot mid last year. Here are a few tips to help you get started.

Designing your chatbot

Have you thought about how people would interact with your bot? Would your bot be leading the conversation and prompting users for all the information required to do their task or would it be artificially intelligent enough to understand the needs of what the consumer is asking or saying? This requires natural language processing (NLP); understanding human language to enhance the user’s experience. It’s important to take into account recursive neural networks and combinatorics. It is ideal to design a UML diagram of your bot. This could help define all the possibilities of how the conversations with your bot could flow.

Picking your tools

One of the biggest factors of developing a chatbot on your own platform as opposed to an existing platform, is your reach. On Facebook’s Messenger platform, your bot can “reach 1 billion people around the world”. Does it make more sense to use a platform which has an established user base already?

The next consideration is whether you would be leveraging machine learning services like, Houndify, or You could also build your own text classifier and plug your chatbot to it. At hipages, we built our own text classifier with MetaMind.

Getting started with Facebook Messenger and Claudia.js

What you will need:
– Set up claudia.js deployment tool (Node.JS 4.3.2 AWS Lambda installation)
– Use Claudia.JS Bot Builder
– Set up a Facebook page
– Set up a Facebook app

1. Setting up the claudia.js deployment tool

npm install claudia -g
npm init
npm install claudia-bot-builder -S

2. Code your bot
Create a javascript file app.js.

const botBuilder = require('claudia-bot-builder');
const fbTemplate = botBuilder.fbTemplate;

module.exports = botBuilder(message => {
  if (message.type === 'facebook') {
    const list = new fbTemplate.List();

    return list
      .addBubble('', 'Australia\'s #1 site to hire trade professionals')
        .addButton('Get Quotes', '')
      .addBubble('Meet our team')
        .addButton('View job openings', '')
      .addListButton('Our Story', '')

3. Create a Facebook app and page.

4. Configure your app
In the dashboard of your app, under ‘Product Settings’, add a product and click on “Get started” for Messenger.

Under “Webhooks”, click on Setup Webhooks.

5. Deploy the bot

claudia create — region us-east-1 — api-module bot — configure-fb-bot

Copy the webhook url and verification token into the screen from Step 4. Select all subscription fields.
Click ‘Verify and save’.

6. Generate access token
Under ‘Token Generation’ in Settings, select your Facebook page and copy the access token back to Claudia.

7. Try out your Messenger bot!
Go to your Facebook page, click on ‘Message’, then ‘Copy Messenger Link’ and ‘Done’. Go to a new tab in your browser, paste your link in and hit ‘Enter’. Type your message and see your bot come to life!

Would love to your thoughts on chatbots or AI voice assistants, feel free to reach out 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s