Chatbot on Facebook Messenger with Google’s Dialogflow(no coding)

Shrabin Tuladhar
Incwell Bootcamp
Published in
7 min readApr 28, 2019

Your business is growing and to make your business grow further, you want instant replies to your customer’s query. For your business to reach at another level at a faster pace, the responses need to be quick and accurate. And this will come only when you understand your audience, first.

Bots, are the new hype in the world of today, and are believed to replace people in the future, which to some extent may be true, but not entirely. Bots will most likely take over tasks that are generally, repetitive and mundane. Rest assured they are here only to make your life easier. And if they try to take over the world? I’m pretty sure people have fail-safes installed for this exact purpose. Now, let's talk about the biggest giant who made it all possible, Google.

Google Assistant is a well-known bot known to enhance the user experience on Android, and it's pretty clear that they have been beating their competition, Siri, by quite a margin. On top of that, Google has taken what they had developed into a product, as a framework and a platform to make and train chatbots. This product of theirs is called Dialogflow.

Dialogflow also has integrations with a wide variety of platforms such as Facebook, Twitter, Slack, Viber and so many more, which opens up a portal for the bots, made on Dialogflow, to interact, like they were trained, on different platforms freely. And the best part is, it needs you to have zero prior experience with coding to make a bot.

And now for the fun part, its quite easy to make a bot and integrate it with Facebook Messenger, you just need to follow the instructions below. This requires at least 2 tabs on your browser.

The first tab will be for the Dialogflow part, the second will be for the Facebook part.

So, let's start with the Dialogflow part:

  1. Go to https://dialogflow.com/ and signup with your Google account.

2. If you had an account already you will be directed to the console, else, you will need to set up the account.

3. After that you will need to Create an Agent, this is the bot that we are making so make sure you give it a good name, like 007.

4. When you are done with that, you will need to set the language and the timezone.

5. There you’ve created a bot, but it lacks functionality so on the page, find a segment called “Small Talk”, open it and enable it.

6. Yay, now your bot can do small talk. To test the bot on Dialogflow, you can interact with it via an input box that says “Try it now” on the page itself.

7. Now that that’s done, to integrate with Facebook Messenger you need to go to “Integrations” tab on the page.

8. You may be able to see many recognizable platforms which allow integrations with Dialogflow, among which you need to click on the Facebook Messenger, then enable it.

9. Now you need to setup a Verification Token, which can be anything you like, that you will remember for the next 15 mins.

We are almost done with the Dialogflow part, but for the integration we need the Facebook part up and running. So, lets jump on to a second tab and login to you Facebook account. then you will need to follow the following instructions:

10. You will need to make a page on Facebook so that the bot can get a face, do note that if you already are an admin of the page you need to make a bot of then you might as well skip this step.

If you don’t own a Facebook page that’s alright, its pretty simple,
- You need to find the pages tab on your Facebook home page.
- If you did click on it you should see a “create page” button.
-Click on it and you can easily create a page (if making a Facebook page is bugging you, do comment your problem below, we shall guide you)

11. Now, that you are ready with your page on Facebook, you are going to need a developers account. So, go to https://developers.facebook.com/ and signup for an account via your Facebook account.

12. Congratulations, you now have a developer’s account of Facebook, now you need to create an app for your page, which is not so hard. You just need to click on My Apps, and now click on Add New App.

13. You must have been prompted to a box asking for display name. You can enter any name you like. Do note that this name will be used to refer to your app, henceforth.

After this just complete the Security Check.

14. Your App is now ready, but we still need to specify that it needs messenger access so, click on the + symbol in the products panel, find the messenger tab, and click on setup.

scroll down

15. You now need to connect your Dialogflow bot to this app, so you will need to get the Access Token.
To get the access token, select the page you created and click on Edit permissions so that you link the app to the page.

After this step your token will be displayed

16. When the access Token is displayed copy it and paste it on the previous Dialogflow tab, Below the Verification Token where it says “Page Access Token”, then click on Start. We are going to need the callback url so, copy the Callback url. We are done with the Dialogflow part.

17. Finally for our app to receive responses from the bot, we need to connect the Webhook and subscribe to events. So click on “Subscribe to events”, paste the Callback Url and type the Verification Token you put in Dialogflow.

18. Now you need to tick all the events you need(tick all if you don’t know what you may need)

19.Click on verify and Save, then in the Webhook tab you will be able to see Select Page, select the page and click on “Subscribe”.

20. Now to test your bot, go to your Facebook wall, in the chat segment search for your page, and try chatting with your bot.

Done, Now all you need to do is train the bot via DialogFlow, by writing responses to common queries that may be thrown at the bot, via Intents.

Note: This bot will only chat with your account and then once you have assigned from the Roles tab of your App page. To make your bot public you need to verify your business.

--

--