This guide is to create your first Facebook Messenger chatbot in just a few minutes. You can even use this on your own business Facebook page and make it smart by adding real content.

Create a Facebook Page

A Facebook messenger chatbot works only on a Facebook page. So you must have a Facebook page. You can use your existing Facebook page or click here to create your first Facebook page.

Create a Facebook Application

It can be a bit confusing for non-programmer but a Facebook application is different from a Facebook page. Facebook Application is used by developers to connect with a mobile app, web apps or with bot engine.

So you must have a Facebook developer account and click on “My Apps” and then “Create App” link.

Facebook App

DialogFlow Introduction & Setup

DialogFlow is a bot engine that provides developers to create a speech or text-based conversational user interface. They can recognize what we say or type and provide a response.

Simply, DialogFlow finds out what is user intent based on the user query, then decides what actions to take and then provides the response.

Below are the simple steps to setup DialogFlow :

  1. Create a DialogFlow Account and go to dashboard.
  2. Create a new Agent who will reply us on the Facebook Messenger chat.
  3. Let’s give it a sample training data, Create an Intent and give it a name “Intro”.
  4. Then go to training phrases and add a question which a user can ask about us. e.g “tell me something about you”
  5. Then add an action. e.g “about-you”. This will be triggerd if intent is matched.
  6. Then add a response. e.g “My name is Sandeep Kumar”
  7. And click on Save and try conversation at right section.

Connect DialogFlow & Facebook Application

You have to take following steps to connect DialogFlow and Facebook application.

Facebook Messenger Settings

  1. first go to your Facebook messenger app dashboard and click on “Set Up” under “Messenger” widget.
  2. You’ll be redirected to Messenger Setting page and here go to “Access Tokens” section and click on “Add or Remove Pages”
  3. Then choose the page you created in the first step and complete the step and you’ll be back to “Access Tokens” section.
  4. Here you’ll see your selected page and click on “Generate Token” to generate a required access token.
  5. One more step is to setup “A Callback Url” under “Webhooks” section but we’ll setup it later. so now back to DialogFlow side.

DialogFlow Settings

  1. Go to Integration and enable Facebook Messenger. Then click on Facebook Messenger title.
  2. Enter here “Page access token” you copied from facebook app setting.
  3. then enter your own a “Verify Token” which you’ll need later so remember it.
  4. And copy the callback url. and click on “Start”. Now it’s time to get back to Facebook App page and setup the webhook.

Go back to facebook app setting.

  1. Go to “Webhooks” section on Messenger setting page and click on “Add callback URL”.
  2. Enter here “Callback Url” you copied from DialogFlow setting in previous step.
  3. and Enter same “Verify Token” which you entered in DialogFlow Setting.
  4. Then click on “Verify & Save” and you’re done with connection between DialogFlow and Facebook Messenger

Test Facebook Messenger Chatbot

Facebook Messenger Chatbot

Go to your Facebook page as a visitor and click on “Send Message” and your Facebook messenger chat window will be opened up and you can type there “tell me something about you” and you’ll see the same response you entered in the Response Phrases.