Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
/ pyfbchatbot Public archive

Facebook Messenger Chatbot built with Python + Flask for Starters.

License

Notifications You must be signed in to change notification settings

xSavitar/pyfbchatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Facebook Messenger Chat Bot for Starters

Install Dependencies

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 Server & Tunnel Connection

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.

Setup Facebook App & Access Token;

  • Create a Facebook App from Facebook Developer Website. alt text

  • Set Up the Messenger Product (you should have a Facebook Page link your bot with). alt text

  • Select a page and enable webhooks. Use the above URL as the callback webhook URL (it should be https). alt text

  • Edit server.py and update the VERIFY_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. alt text

  • Also generate a page access token for that page. alt text

  • Edit server.py and update the ACCESS_TOKEN with the new token we got.

Testing the bot

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. 👍