Creating a ChatBot using Python for my Facebook Page.
- Language: Python
- Packages:
Flask & Requests - Input:
From your Facebook Page - Output:
Message Deliveries, Message Reads, Messages, Message Echoes, Messaging Options, Messaging Postbacks, etc info.
Follow the steps described below.
Install Flask and requests using pip if you already don't have any in your machine.
pip install flask
pip install requests
For the headache free webhook integrations and securing tunnel connection with facebook.
Install ngrok from web - ngrok
-
Run the dev server using
fb_chatbot_server.py -
Now use
ngrokto tunnel the connection, as:
ngrok http 80 -
Now, you'll get to see a active url for your local server, as:
https://4e9f87b7.ngrok.io
- Create a Facebook App.
- Add a Product-
Messenger. - Enable webhooks. Use the above URL as the callback webhook URL.
- Edit fb_chatbot_server.py and update the
VERIFY_TOKENwith the token you set. - Once the callback is verified, subscribe the app to one of your pages.
- Generate a
Page Access Tokenfor your page. - Edit fb_chatbot_server.py and update the
ACCESS_TOKENwith the new token.
For any query, ping me on
- LinkedIn: @jabhij
- Twitter: @jabhij
- Web: LetUsTweak
Hope, it helps!! ヅ