![chatbot facebook chatbot facebook](https://www.chatbot.com/integrations/facebook-messenger/buttons.e355bdbd402f50c6bd80147d8477599247efabc99c2e8b47ee8b2259f2dd4477.png)
CHATBOT FACEBOOK CODE
The express code in the Facebook guide simply echoes back what the user typed.Īgain, we’ll create an API Builder Custom API with the same endpoint, but it will be a POST this time. In this step, you will also generate a Page Access Token. This is described in section 5 of the Facebook Messenger Platform Quick Start Guide. When a user types into the chatbot, Facebook will make a POST request to the same endpoint described above. I found that I needed these additional two subscription fields checked in order to get the chatbot approved by Facebook. Another guide I found suggested also subscribing to messaging_optins and message_deliveries as well. This is covered in the next section.Īnother issue that I faced following the Quick Start Guide is that the instructions mention selecting messages and messaging_postbacks under Subscription Fields. The one issue using this method is that I need to manage two Facebook page access tokens. The production of Facebook chatbot will use the API Builder production API for its webhook. My solution was to create two bots, one for dev and one for production.ĭuring development, I use the dev chatbot and ngrok, so that Facebook can actually call an API Builder API running locally in dev mode. But that poses a development conundrum, since it is very slow to make changes, and then publish to production after each change. So, you need to publish the API Builder project and then use that URL for the Facebook chatbot. With API Builder, you are typically developing and testing the API Builder project locally and then publish it when you are done. Here is where I faced the first challenge.įacebook does not allow me to change the webhook URL once I enter it into the Facebook developer portal.
CHATBOT FACEBOOK HOW TO
My Custom API, in the file /api/fbwebhook.js, is shown below:ĭescription: 'this is an api that shows how to handle requests from the FB chatbot',
![chatbot facebook chatbot facebook](https://mythemeshop.com/wp-content/uploads/2017/07/Facebook-Chatbots-Guide-Blog-Image.jpg)
In API Builder, I chose to implement this as a Custom API. The Quick Start Guide provides the Express code for this. In step 2 of the Facebook Messenger Platform Quick Start Guide, we need to provide the URL of an API endpoint that can take a GET request. I’m not going to cover the Facebook chatbot creation as it’s well documented in the QuickStart guide, so let’s dive into API Builder. How to Build a Facebook Bot App Using Node.js was also a useful resource. I only followed steps 1 – 6 of this guide to get the basics implemented. I found the Facebook Messenger Platform Quick Start Guide to be a great place to get started with the creation of a Facebook chatbot. API Builder will also be used to implement the artificial intelligence (AI) required to make the bot (seemingly) intelligent. The basic idea is to create the bot on Facebook and then create the Facebook-required APIs (webhooks) in API Builder. You can expect an experience similar to the screenshot below where I am interacting with the chatbot in the lower right-hand corner of the page: You can view and interact with the chatbot here. This post will not dive into the AI aspect of chatbots but focus more on the mechanics of setting up API Builder for implementing a Facebook chatbot. A Facebook chatbot can be used to engage employees or clients who visit your page and allow them to discover information about your company and products in a more natural chat format. In this blog post, we describe how to use API Builder to create a Facebook chatbot.
![chatbot facebook chatbot facebook](https://i.pinimg.com/originals/57/73/5b/57735b735ba05c5634c787b0b6915bd9.png)
![chatbot facebook chatbot facebook](https://botsociety.io/blog/wp-content/uploads/2018/01/Screen-Shot-2018-01-27-at-3.57.55-PM.png)
In a prior post, we described how to use API Builder to implement a Twitter Bot that posted tweets, retweeted and also followed anyone that followed the bot.