git clone
the code for the bot
git clone https://github.com/botshala/basic_echo_bot.git
-
Every messenger bot must be associated with a facebook page, Add your page access token to this line
-
Next we need to activate the webhook, we will use heroku to deploy our bot. Sign up for it and download the cmd-line toolbelt
#make sure you're in the parent directory
cd basic_echo_bot
#login to your account using the toolbelt
heroku login
heroku create
#commit your changes
git add .
git commit -m 'pushing code to heroku'
git push heroku master
#run your code on heroku servers
heroku ps:scale web=1
#see the logs for debugging
heroku logs -t
-
Verify if your project is deployed correctly by viewing the logs and going to the public url of your app (e.g arcane-retreat-27414.herokuapp.com)
-
Make sure the VERIFY_TOKEN you enter on the fb dashboard is the same as in your code
-
Once the webhook is activated and verfified, go to the fb dashboard and subscribe to the facebook page you want your webhook to listen to.
-
Send a message to your page, and view the logs
heroku logs -t
to debug any errors -
make changes to your code and re-deploy it on heroku as follows
git add .
git commit -m 'made some changes'
git push heroku master
#now re-run it on heroku
heroku ps:scale web=1
#now see the logs, to check whether the error still persists
heroku logs -t
- FAQs
- istall requests if you haven't
sudo pip install requests
- disable the static file directory flag
heroku config:set DISABLE_COLLECTSTATIC=1
- make sure your git tree has heroku as origin
heroku git:remote -a {{YOUR heroku_app_id}}
- Try shutting down the server and getting it back up again by
heroku ps:scale web=0
&heroku ps:scale web=1
respectively. - Try opening this URL
https://{{your-heroku-app-id}}.herokuapp.com/facebook_auth?hub.verify_token={{your-webhook-verification-token}}&hub.challenge=12322