Skip to content

botshala/paytmcare

Repository files navigation

Making a basic echo bot in python & Django

  1. git clone the code for the bot
git clone https://github.com/botshala/basic_echo_bot.git
  1. Every messenger bot must be associated with a facebook page, Add your page access token to this line alt text

  2. 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 
  1. 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)

  2. Activate your webhook alt text

  3. Make sure the VERIFY_TOKEN you enter on the fb dashboard is the same as in your code alt text

  4. 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. alt text

  5. Send a message to your page, and view the logs heroku logs -t to debug any errors

  6. 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
  1. 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