How to create a Facebook Bot

1 - Create a Facebook App and Page

Create a new Facebook App and Page or use existing ones. Go to the App Dashboard and under Product Settings click "Add Product" and select "Messenger".

img

2 - Get a Page Access Token

img

In the Token Generation section, select your Page. A Page Access Token will be generated for you. Copy this Page Access Token. Note: The generated token will NOT be saved in this UI. Each time you select that Page a new token will be generated. However, any previous tokens created will continue to function.

3 - Setup Webhook

In the Webhooks section, click "Setup Webhooks".

Enter a URL for a webhook, enter a Verify Token and select message_deliveries, messages, messaging_optins, and messaging_postbacks under Subscription Fields.Important: you have to replace <'token'> for your real token!

img

4 - Save the token into Botmessaging

img

Now you have to create a Facebook channel and paste the token in the token field.

You have to press Add in order to add a Facebook channel. After this you will see this dialog with has two fields, the name and the token. In the field name you can put whatever you want a call your bot. In the token field you have to put the token that BotFather gived to you in the last step. This is all, You have your first bot ready to use!