The Facebook Messenger app supports a connection of a bot that can then be used to send and receive messages on behalf of a designated page that belongs to the bot.
The following steps are necessary for the correct setup.
Log into Facebook, navigate to Facebook developer portal and create a new app.
Once you create the app, you will be shown the Product Setup page. Select Messenger and click Set up.
Scroll down a bit on the displayed page until you see the Webhooks section. Click on Setup Webhooks. You will be promted to fill in a New page subscription form. The requested values can be generated through Integromat.
Log into your Integromat account and create a new scenario. Add the module - Facebook messenger- Watch messages as the first module to your scenario. Click the Add button to create a new webhook. Enter a webhook name and a verification token of your choice into respective field. You will need this verification token later. Click Save.
Clicking the save button will generate an URL of the webhook. Copy this URL into your clipboard.
Go back to the New page subscription form. 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 4. In the Subscription Fields section, select
messaging_postbacksand click Verify and Save. A green check mark next to the webhook indicates that the validation has run successfully.
Now you have to generate an access token for the bot. Go to the Token generation section (just above the Webhooks section) and select a page for which you want to generate the access token. Copy the generated access token into your clipboard.
Once you have set up a connection in both directions, you can finish your scenario.
In order 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. For more information on how to set up the roles see the official Facebook documentation. The settings of the roles is done in the the app settings in the left menu.