Whats the need?
Heroku logs vs Facebook Messenger UI
No explanations on which one is pretty!
It’s really easy to get the server logs on the messenger bot rather than seeing them on black terminal screen.
I was working on scrapy spiders where I needed to check the logs every 300 sec. It would have been great if I was to receive them on my phone when the spider is at work while I am away.
So I created an API which sends me the params and data it receives on the facebook chatbot as a message.
Building a chatbot in python is quite easy. Follow this blog to set up an echo bot and host it on Heroku.
The recipient id of the user with respect to bot-user is fixed. Figure out that id (console on the above echo bot to get it) and set it as the environment variable on Heroku (SENDER_ID). Also, set the PAGE_TOKEN and SECRET (So that only you the authentic user can use it) as the environment variable. For Full Code – Visit here.
- Clone the repo
- Set the above Environment variables (SENDER_ID, PAGE_TOKEN, SECRET) in Heroku
- Deploy your app and get your unique logging URL which sends you the message on facebook on every log you make
In my case, my URL is: https://facebooklogger.herokuapp.com/api/SERVICE_NAME?secret=ABHINAV_SECRET
The response of the POST request on facebook chatbot is shown.
Life is short! Spend your time wisely!
For any help/feedback – contact me at firstname.lastname@example.org