Communication

Facebook Messenger

7min
with facebook messenger apps in {{product name}} , you can watch and send messages, send an action, upload an attachment, or get a sender in your facebook messenger account to use the facebook messenger modules, you must have a facebook developer account you can create an account at https //developers facebook com/ https //developers facebook com/ refer to the facebook api documentation https //developers facebook com/docs/graph api for a list of available endpoints connect facebook messenger to {{product name}} to establish the connection with a trigger module , you must create a webhook with a verify token and add this information into your app in the facebook developer portal to establish the connection with an action module , you must generate an access token in your app in the facebook developer portal the following example, facebook messenger docid\ mspyyiygbqkcujxidcxgy , describes both processes in a possible {{scenario singular lowercase}} how to create a bot and connect it to facebook messenger and {{product name}} the facebook messenger app supports a bot's connection that can then be used to receive and send messages on behalf of a designated page that belongs to the bot log in to the facebook developer portal https //developers facebook com/apps and click create app in the upper right corner choose other as the use case for your app and click next add your app name and contact email , then click create app once you create the app, you will be shown the product setup page select messenger and click set up scroll down until you see the configure webhooks section and click configure click the add callback url button you will be prompted to fill in the edit callback url and verify token fields the required values can be generated through make open a new tab and log into your {{product name}} account, and create a new {{scenario singular lowercase}} add the module facebook messenger > watch messages as the first module to your {{scenario singular lowercase}} click create a webhook enter a webhook name and a verify token of your choice into the respective fields you will need this verify token value later click the save button clicking the save button will generate a url for your webhook copy this url to your clipboard go back to the edit callback url dialog in your facebook developer account in the callback url field, enter the url from your clipboard, and in the verify token field, enter the same token that you entered in step 6 click verify and save to save the dialog under generate access tokens , click connect in the dialog box that opens, choose the pages you want your app to access and click continue and save click got it you will return to the generate access tokens section for your chosen page, click generate in the token generated dialog box, confirm that you understand and then copy the token to your clipboard to create a connection between {{product name}} and facebook messenger, add a send a message module and click create a connection enter the access token from the previous step into the access token field and click save map the sender id to the page scoped user id field and specify the message text in the send a message module set up the send a message module and run the {{scenario singular lowercase}} to test your bot testing the facebook messenger bot to test the bot application, you need to facebook messenger docid\ mspyyiygbqkcujxidcxgy facebook messenger docid\ mspyyiygbqkcujxidcxgy facebook messenger docid\ mspyyiygbqkcujxidcxgy (created by the app administrator) when logged in as a test developer to trigger the watch messages module in your {{scenario singular lowercase}} set up a test developer role to test your application before publishing it, you need to set up roles for developers who will test it for non developer accounts, the app does not respond until it is officially released you need two facebook accounts to test the app the first account that creates the app (bot) is the facebook page owner the second account that is set up as a verified facebook developer account ( how do i verify my developer account on facebook? https //www facebook com/help/167551763306531 ) and sends the test message to the facebook page log in with your second developer (test) account and confirm the request on the https //developers facebook com/requests https //developers facebook com/requests page run the {{scenario singular lowercase}} after the test developer account is set, run your {{product name}} {{scenario singular lowercase}} , log in to facebook (with your test developer account credentials), and open the public page you want to test the bot with send a test message to the test page send the message to the page to test your bot conditions that have to be met while testing the facebook account you write a message to the facebook page must be set as the developer of the app the bot cannot send the message first (anti spam policy) the app test user must initiate the conversation with the developer role, your second account for more information on how to set up the roles, see the official facebook documentation https //developers facebook com/docs/apps/test apps