How To Build Your Own Facebook Chatbot That Generates Leads On Autopilot – The Ultimate Guide

How to build chatbot

Have you ever wanted to build your own chatbot

But didn’t know where to start? Here is the best complete guide on building your own Facebook lead generation bot. Dimitry Kagan has broken everything down for you to get started.

Facebook chatbot lead generation

Facebook chatbots are all the rage right now in the digital world. Everyone and their mother are talking about them. but can they really help marketers drive business goals?

Ever since Facebook released the feature in late 2016, There’s been a lot of hype around it.
But there’s still not enough data to show that bots are actually useful for marketing.

facebook chatbot popularity

I was curious to test this idea.

So I set out on a mission to build a Facebook chatbot that can generate leads for a client of mine.
The goal was simple: the chatbot would talk to “cold” users that clicked on an ad, segment them to groups based on their need and interest, and finally – get their contact information.

In the first 60 days of it’s existence, the chatbot had conversations with 3,200 users, and generated 1,125 qualified leads. That’s a 35% conversion rate.

Almost double the performance of our landing pages, and with cheaper clicks to boot!

In this guide I’ll show you exactly how I built it, and what I’ve learned in the process.
But first, let’s start from the top: the thought process that led me to create a Chatbot.

What led me to create a Facebook Chatbot? the pain of mobile lead generation

If you advertise on Facebook, you know that most of your ad traffic is usually mobile.
And what popular options do we have for lead generation with Facebook Ads?

  1. Create a landing page and send traffic to it with a “Clicks to Website” Campaign
  2. Collect leads on Facebook with a “Lead generation” Campaign

Landing pages are probably the safest bet. They’ve been around for years, and served marketers as a tool for displaying sales copy and converting traffic to leads.

But anyone who’s ever built a landing page knows how hard it is to convert Mobile traffic.

We have to cram a lot of copy and images in an extremely narrow space, have it load really fast, and make the Opt-in form extremely short and irresistible.

This is very hard, especially with content rich landing pages.

The second option is to use Facebook’s native lead-gen forms, without landing pages.
When this feature was first introduced I was sure that it’s a game changer. “A user clicks a link and his contact info is auto-filled by Facebook? Amazing!”, I thought.

But after running a few of these campaigns, the excitement wore off.
Apparently, the ease of filling out Facebook’s lead forms for the user, often breeds unqualified leads. Some of whom don’t even realize they gave away their contact information.

One of my client’s mobile campaigns was tanking. The landing page was bringing in too little leads, and the lead-gen campaign generated many cheap leads, but they were low quality.

I was frustrated…

I needed a better way to acquire mobile leads

This led me to test out a “Messages to Page” campaign to see how it goes…

…and to my surprise, it went pretty well!

We started getting messages from potential leads and had a Customer Service Rep chat with them and convert them. Things were finally looking up.
But when I scaled the campaign, we found ourselves drowning in hundreds of Facebook page messages, without a way to manage and measure what was going on.

The messages feature on Facebook pages is built like a mini helpdesk system, but it’s not designed to handle leads. There’s no way to save and export the person’s contact information. And it’s really hard to keep up with many conversations.

Now, after finding an angle that works, I knew that all we needed to improve this is a smarter, automated system, that could replace our Customer Service people 95% of the time, segment leads based on their interest and download their contact information somewhere.

Enter a Facebook Chatbot!

I created a Facebook Chatbot for the client’s Page, and now it chats with leads even while I sleep. When users ask questions, it answers and convinces them to leave their contact information.

It saved us countless hours of manual work and lifted our conversions.
So, you might say I’m kind of in love with it ❤

And now, romance aside. Let’s show you how you can build one yourself!

The 4 tools we’ll need to create our Facebook Chabot campaign:

1. A “Messenger Destination” Ad

Your Facebook chatbot can exist on your Facebook Page and respond to messages from users organically.

But most Facebook pages aren’t getting a lot of organic messages, so we’ll need a paid traffic campaign to lead users to chat with our bot.

This requires a regular “Clicks to Website” Campaign, only instead of sending users to a website URL, you’ll pick “Messenger” as the destination, like so:

facebook chatbot - messenger ad

Here we can choose between two options:

  1. Send an initial text message to a user after he clicks on our ad.
  2. Send an initial JSON message that can include buttons, images and links

Because we’re building a Facebook chatbot to handle all conversations, we can leave these fields empty.

Pro tip: In the ad itself – it’s a good practice to tell the users to use a certain keyword within the conversation to make the bot trigger the right response quickly.

What does this mean?

For this guide, I’ll create a Facebook chatbot that generates leads for a landing page building service I offer.
So in the ad leading to the chatbot, I’ll write something like:

“Want me to create a great landing page for your business?
Click this link and type: “landing” in the chat”

That way, when people will chat with your bot, they’ll know they can use this keyword. And you can program the bot to respond to it with an appropriate answer.

This is also a great way to separate different campaigns to the same chatbot.

If you choose to run campaigns for different services like: landing pages, website design, coaching etc. it makes sense to ask the user to type a different keyword for each of these campaigns. More on this later.

Now let’s get to building our chatbot!

2. Building a basic Facebook chatbot with Chatfuel (No Coding required)

There are two ways to create a Facebook Chatbot:

  1. Build one from scratch using code and Facebook’s API / paying a developer to do so. (probably a lot of money).
  2. Build it on a free platform made for people who don’t code (like me)

You’ve probably guessed that we’re going to cover the second option here.

There are a few platforms that allow you to build chatbots for Facebook Messenger.

The big ones are: Manychat, and Chatfuel.

They’re all based on a freemium model. Meaning you can start a bot for free, and start paying monthly after reaching a certain users/messages cap.

In this guide, we’re going to use Chatfuel, which is free up to 100K messages/month.
I found it to be the easiest to use platform.

I’m not going to do a complete overview of Chatfuel, because that would make this post too long.
But I will explain the functions we will use to create a basic Facebook Chatbot.

If you haven’t played around with a bot builder before, you can watch this 12 minute video explaining the basics of Chatfuel. But for now, you can skip the video to finish reading this guide, and return to it later when you actually start building the bot.

Write a script for your Chatbot

Before we build the chatbot in Chatfuel, it’s best to plan and write down our desired conversation script: “What will our Facebook chatbot say and when”.

I usually do this by drawing a simple flow chart on a piece of paper or a Powerpoint/Keynote.

Here’s what a simple conversation flow might look like for a chatbot that needs to generate leads for a landing page building service:

facebook chatbot script

As you can see in the script, the chatbot is entirely focused on landing pages, and it’s only goal is to make the user type his contact information if he needs a landing page, or end the conversation if he doesn’t.

Since this chatbot doesn’t have an artificial intelligence, it’s only as smart as you make it.

So you must have default answers ready for users that “go off script”.
If a user starts asking unrelated questions, the chatbot should drive the conversation back to discuss landing pages 🙂

And if a user types the keyword: “landing”, this should trigger the chatbot to go straight to the landing page block in the script.

Pro tip: build a lean chatbot first (an MVP). Start off with the most minimal chatbot script that does the job. Launch it, see it in action and only then start tweaking and adding more complex layers according to the users’ behavior.

Create the chatbot in chatfuel

At first, Chatfuel will ask you to name your bot, and connect it to a Facebook Page of your choice.

Then you can start building your Facebook Chatbot using the left menu, which consists of:

1. Build – This is where you’ll build the conversation according to the script we prepared before.

2. Setup AI – Here we can create rules for the bot with conditional logic: User types X, the bot responds with Y, etc. We’ll want to create at least one rule for users who type landing page related keywords, to move them to the landing page script.

3. Broadcast – Here you can create broadcast messages to all users who had conversations with your bot. kind of like email blasts.

Chatfuel has more features, but we’ll use only 1 and 2 in this guide.

Now, let’s get to building:

Create a blank chatbot and connect to a page

In the Chatfuel Dashboard we’ll click on the “Create a blank chatbot” button, then we can press the “Gear” icon on it to rename it.

Then, we can connect it to our Facebook page by pressing the “Connect to Facebook” button.

Now, let’s click on the bot we created – and enter the building menu. To build our chatbot conversation, press the “Build” on the left menu. The bot has 2 mandatory built-in blocks:

1. Welcome message: The first message that each user will see when starting a conversation with our bot.

2. Default message: This message will appear when a user types something “off script” that our chatbot doesn’t know how to answer.
We’ll want this message to bring the user back to the script.

The Facebook Chatbot structure:

A chatbot is made out of blocks. each block has it’s own purpose. The welcome block should greet the user and offer him choices of how to proceed with the conversation.

Each block consists of conversation cards. The basic cards are: Text message, Image and quick replies. The advanced cards are called plugins – these will let us use data from the conversation and export it to 3rd party systems, like email, spreadsheets, etc.

As for the advanced plugins in the “+” area, in this guide we’ll only use the following:

User Input – Saves user input in a variable we choose

Go to block – Makes the bot jump between block when certain conditions are met

JSON API – This card will connect our bot to Zapier using a Webhook.

Typing – This card displays the “Typing…” widget in conversations with our bot, and makes the conversation feel more “human” and natural.

The Welcome block

Here we’ll greet our users and explain what they can do in the conversation.

This is how I built it: A simple text message, followed by a “typing” plugin, another text message that asks a question and 2 quick replies. each reply can link to another block in the bot structure.

I ask the users if they need a landing page for their business.

If they type “yes” – go to the next block, to get their contact information.
If they type “no”  – go to “end conversation” block and ask them to leave a message.

facebook chatbot - welcome block

Get phone number block

In this block our goal is to extract a user’s phone number, and push the conversation forward.

We’ll start with a text block to let him know what we need from him, and then use a plugin called “User Input” that asks for a phone number and saves the answer to a variable called “phone”

This variable holds a unique value per user, and later we’ll send this variable to Google Sheets.

Finally we’ll add a plugin called “Go To” to move the user to the next block “Website URL” – that does the same thing only it extracts a website URL instead of a phone number.

We can even duplicate the entire block to save us some time.

facebook chatbot - phone block

We’ll do the same with all other inputs we want to extract from the user, and when we’re done – our last block should send all the variables to Google Sheets.

Sending lead data from Chatfuel to Zapier

Now it’s time to send all of our variables to a CRM of our choice, in this case: Google Sheets.

We can’t do that directly from Chatfuel. So we’ll send our data to Zapier with a Webhook, and then move it to any CRM we want (Zapier supports pretty much all the apps we can imagine :)).

To send the lead data to Zapier, we’ll use a plugin called “JSON API”.

In the “user attributes” part – we’ll fill in all the variables we saved from our conversation. notice that we didn’t have to ask a user for his first and last name because Chatfuel does this for us.

In the “url” part we need to enter our Webhook URL that we get from Zapier (Explained later):

facebook chatbot - json api

Setting up AI Rules for your Facebook Chatbot

When people chat with our bot, they can either select the answers we provide using quick replies or buttons, or they can type text answers.

When a user types text answers, our bot will display it’s default reply, unless we create an AI rule for certain keywords our users can use.

For example, let’s create this rule: if a user types a landing page related keyword such as “landing”, “page”, “pages” etc. The chatbot will reply with the Phone number block, assuming that the user is interested in landing pages.

We can also create “you’re welcome” responses when a user says Thank you or equivalent phrases. Go to “Setup AI” in the left menu and create these rules:

3. Use Zapier to get leads to your CRM

If you haven’t used Zapier before, it’s a Magical tool that can send information between apps.

A process that connect apps together is called a “Zap”. Each Zap run is called a “Task”.
Now we’ll create a Zap that connects Chatfuel to Google sheets, and each time a user will talk to our bot, Zapier will run the Zap and send the data to a Spreadsheet in Google Sheets.

The free version of Zapier offers 5 Zaps and 100 tasks/month.

Each Zap consists of a Trigger and an Action. The trigger is the thing that triggers our Zap. and Action/s is what we want to happen when it triggers.

So we’ll create a new Zap. it’s trigger will be a Webhook (when a user gets to the last block in Chatfuel, this will trigger the Zap).


Zapier will give us a unique URL for the Webhook, we will then copy this URL  and paste it into the Chatfuel plugin (JSON API) we created earlier.

The action of our Zap will be “Google Sheets”, and there we’ll have to map the variables we sent from Chatfuel to respectable columns in our Spreadsheet.

So first, we need to create our spreadsheet:

At this point, if you haven’t done it already, you should test your Facebook  chatbot and have a conversation with it. Press the blue “Test this chatbot” button in the Chatfuel menu.

This should create data to pass to Zapier.

Now, in the Google Sheets action, we’ll map our variables:

facerbook chatbot - create google sheets row with zapier

Now all we have to do is test our steps in Zapier, turn our Zap on and we’re done!

After this process, your spreadsheet should have one row with the lead details from Chatfuel (After you ran a test chat with your bot):

facebook chatbot - filled google sheets row

Boom! you are now the proud owner of a fresh new lead from a Facebook Messenger chat 🙂

Want to test the Facebook chatbot I built for this guide to have a feel for it? Click this button:

In conclusion,

A good Facebook Chatbot is like having landing page that can talk!
Think about it. Instead of having your potential customers read information off of a static web page, they can have an engaging conversation with your Chatbot.

The chatbot technology is still at it’s infancy, but I it’s easy to imagine how Chatbots will play a bigger part in Digital Marketing campaigns. These are the key benefits of Chatbot campaigns:

1. Conversations > Forms

It’s extremely easier to answer quick questions in an engaging conversation than filling out a form. there are of course issues of validation, but this could be improved easily in the future.

2. Always on

Chatbots are available 24/7 and can talk to multiple users at the same time, making them more effective and scaleable then human reps at dealing with client’s questions all day, every day.

3. Facebook Messenger is a rapidly growing channel

As of April 2017, Facebook Messenger has 1.2 Billion monthly active users! People spend more and more of their time chatting on Messenger, so it’s only natural to tap into this channel and use it for Marketing purposes.

All credit of this article is from Dimitry Kagan, with many thanks. You can see the original article here.

    Would love your thoughts, please comment.x