Install Flask
& requests
packages using Python's dependency package manager(pip
);
pip install Flask requests
Download and Install ngrok from the Official Ngrok Website.
Run the dev server using:
python server.py
Use ngrok
to tunnel the connection;
./ngrok http 5000
You will see the url for your local server. Something like: https://6cecffb8.ngrok.io
.
-
Create a Facebook App from Facebook Developer Website.
-
Set Up the
Messenger
Product (you should have a Facebook Page link your bot with). -
Select a page and enable webhooks. Use the above URL as the callback webhook URL (it should be
https
). -
Edit
server.py
and update theVERIFY_TOKEN
(you set, in this case "secret") &ACCESS_TOKEN
(randomly generated token). -
Once the callback is verified, subscribe the app to one of your pages to activate the bot.
-
Edit
server.py
and update theACCESS_TOKEN
with the new token we got.
Visit your Facebook Page to chat with the bot. Make sure to follow all the steps above in order for the bot to be activated on your Facebook Page. 👍