As a so-so programmer, I recently looked up how to create a Facebook messenger bot that could automatically share new posts from my blog (as an alternative to someone subscribing via email or RSS). Normally, if I can find a suitable Github library or clear enough tutorial, and the app isn’t too complicated, I can hack it and get it working. What I was surprised to find is the social media bot ecosystem has already evolved so quickly that you can build your own Facebook messenger bot in a few minutes without writing a single line of code. Even better, you can do it completely free. So I thought I’d share a quick tutorial on how to make your own marketing or customer service bot (or just something to impress your friends).

Want to see my messenger bot in action? Click the button below to chat with the (simple AI version) of me [note: this may launch the messenger conversation on your phone if you have the app open there but not in your browser].

test the facebook messenger chatbot

As you can see, it’s a pretty simple, but there are a lot of different possibilities if you take the time to invest in your bot’s communication logic. So let’s get into the tutorial.

Step 1 – Sign up for a free account with Chatfuel

In the past year many different chatbot development platforms have launched. I compared a few different ones and liked Chatfuel for its ease of use, simplicity and clean UI. Click the “get started” button and authenticate with Facebook.

Facebook bot developer

Step 2 – Decide if you want to build your bot from scratch or use a template

This decision is really up to you. I decided to build mine from scratch just to understand the process better, but if you’re in a hurry you might just want to use a template. If you’re looking to market your business, startup, writing, or project by increasing subscribers to your content, two good templates to choose are the “Obtain users’ permission to send broadcasts” or the “TechCrunch publisher template.”

Chatbot templates

Step 3 – Think Through and Design the Main Logic Flow of Your Messenger Bot

You can get a quickstart using either of the two templates I mentioned above, but I’ll walk you through the thought process of designing your bot from scratch.

The first thing to think through and write out in a doc or flow chart is the user experience flow or conversion funnel you want the conversation to enable. What does the person your bot’s going to interact with want? How can you offer them some value? And what’s your desired outcome?

For me, my objectives that the bot’s logic needs to enable are fairly straightforward:

1. Welcome you to the bot, introduce myself, and set expectations for the interaction we’re going to have

2. Ask if you’d like to become a subscriber [conversion call-to-action]

3. If you answer “yes,” I’m adding you to my subscriber list

4. If you answer “no,” I’m thanking you anyway and seeing if there’s anything else I might be able to help with

5. Try to be polite, succinct, and, hopefully a little light-hearted and entertaining through the entire process (for example, you can ask my bot for a gif, and, if it correctly understands your request, it’ll share one of my personal favorites)

Step 4 – Enter in the Conversation Logic and Content

Once you’ve designed your logic, then it’s all about using Chatfuel’s ‘building blocks’ like LEGOs to assemble different parts of the conversation. Essentially, you have only a few types of blocks:

1. Conversation blocks where you say something

2. Button blocks where your user can trigger an action or outcome

3. Data blocks that capture data about the person you’re having a conversation with

4. Listening blocks that can help make your bot’s responses more relevant

I’ll come back and show you examples of all these shortly, but it’s just like a recipe in cooking. Once you know the dish you’re looking to make, it’s all about the ingredients and the steps to bring them together.

So let’s start by building a simple welcome message that explains what your bot is about. Click into the ‘build’ section of a bot you’ve created and edit the ‘Welcome’ message to something like this:

Facebook messenger chat bot welcome

Notice I also add the “show typing” with varying different lengths throughout my bot’s logic to make it feel more conversational. If you skip this, your bot’s program logic will process things and respond so quickly it feels very disruptive and unnatural to the person you’re speaking to. Make sure to humanize it a bit.

Then, after the bots been conversational for a bit (I use a gif as an ice-breaker after my welcome), I add my call to action. My recommendation is to add this to your welcome stream after a longer typing delay to ensure the logic is followed. Here’s an example of my CTA:

marketing bot call to action

For the purposes of generating my conversion outcome and the rest of the app activity, what’s important are the two connected buttons. Here I’ve essentially created a binary outcome — unless you just ignore my bot, you’re either going to answer “yes” or “no.” Whichever answer you pick has another block tied to it (for example: “Subscription success”) which will carry the conversation forward if it’s selected. Chatfuel refers to this as “AI” (artificial intelligence).

messenger button logic

Clicking the “Sounds great” button triggers the “Subscription success” block, which introduces another important block type I referenced earlier, the data or ‘user attribute’ block.

facebook data segmentation

You can probably already see how powerful this is. Just like a CRM or marketing automation system, we can trigger and create data tags that we attach to the people we’re talking to. These user attributes can then trigger additional logic or be used for segmentation. Here, if you opt-in as a subscriber, I’ve created the custom user attribute ‘subscribed’ and set it to ‘true’. But again, this is completely customizable and you can prompt, create and later segment by any user attributes you like.

There’s a lot you could potentially do here, like send these user attributes out through Zapier to generate and save them to a spreadsheet. That’s outside the scope of this tutorial, but I’d encourage you to think creative about the automation possibilities with the data your app collects.

Great, so at this point, if the conversation has gone well and the person I’m chatting with agrees to subscribe, I’ve update their value and added them to my messenger bot’s subscriber list. Now there’s just one more step to go.

Step 5 – Finalizing the Remaining Facebook Messenger Bot Automation

Now that our bot app is set up to acquire blog subscribers, we need to finalize how our bot’s going to deliver our subscribers that content. We can do that by heading over to ‘Broadcast’ to set up a Facebook messenger webhook. To get somewhat technical for a second, a webhook is really just an HTTP callback, a way for an app to push data to some other API endpoint destination in response to a trigger. “If this, then that,” with data. So what we need is logic in our app that says, “if {{ someone is a subscriber }}, then {{ send data to this service }} in order to {{ trigger outcome }}.”

Facebook messenger webhook

Click on “Autoposting” under “Autopost from Existing Source,” and you’ll see a menu of integrations. Two of the best logic-based integrations are Zapier and IFTTT. You could set up your auto-sender with either one, but we’ll chose Zapier (you’ll need a Zapier account as well if you don’t have one).

facebook messenger API webhook

From there, you’ll just need to follow the instructions.

1. Go over to Zapier (and set up an account if you don’t already have one)

2. Create the Zap by giving Zapier your blog’s RSS feed (or whatever other data source you might be using), along with your Chatfuel API key. Zapier will automatically help you test and validate that you entered things correctly.

Zapier integration

3. There’s no step 3. Congrats, you built your first Facebook messenger bot. Now all the updates from your blog or email marketing system are automatically sent to your users.

That’s all you really need to do; with the help of platforms like Chatfuel and Zapier, just take it step by step and you can get amazing results. And again, spend some more time studying Chatfuel and Zapier, looking at different recipes, and thinking about how you can combine the different building blocks to delight your chat customers and achieve your goals. There really are an immense amount of possibilities and cool outcomes you can engineer.

Finally, even if you’re not a programmer but you want to better understand the underlying mechanics of how your Facebook bot works, I’d encourage you to check out Facebook’s official messenger documentation. Yes, there’s a lot of abstraction and magic when you use middleware like Chatfuel or Zapier, but sometimes it’s also good to know what’s happening ‘under the hood.’

So with that, hopefully you’ve just jumpstarted your journey into making chatbots and using them to achieve important outcomes like:

1. Generate leads and growing your subscriber base
2. Making your buyer or customer’s journey simpler
3. Increasing customer satisfaction through help experiences
4. Automatically distributing your content via messaging apps and API
5. Delivering targeted content based on user feedback and interests
6. Learning some basics about AI

And, most importantly of all, hopefully you just saved yourself a lot of time you can use to go focus on other important priorities. Hope you found this helpful, and feel free to get in touch (you could even use the bot 😊 ) if you get stuck or have any questions.

test the facebook messenger chatbot

p.s., if you are an aspiring programmer and want to develop your own bot and go deeper with social automation, check the nice python tutorial Hartley Brody put together on building messenger bots.

If you found this helpful, share it with a friend, teammate or your network

Leave a Reply

Your email address will not be published. Required fields are marked *