This was an exercise in creating a basic facebook chat bot. It has now been taken offline.
- Here's a tutorial I liked
- Here's the awesome second part
- What this bot does: Responds to facebook messenger chats with pre-specified responses it randomly selects
- A bit more involved than the twitter bot
- One major difference: you have to host your facebook bot on a webserver so there can be a continuous back and forth of information
- How to get the bot going:
- Python code is built using Flask - a web framework for Python code
- Create an app on the facebook developer site and set up client/access keys/secrets in code and on facebook
- Use ngrok to create a temporary URL for you to host your app from your machine
- Set up a webhook on facebook using this URL for secure back and forth communication between facebook messenger and your webserver
- One thing that confused me: only people you give admin priviledges to your bot on facebook can chat with it unless you submit your bot to facebook for an official review
- hosting bots via ngrok is bad
- need to constantly run both ngrok and your code on your machine to keep your bot to be alive
- if you want to update your bot you need to
- stop running your python code
- stop ngrok
- update python code
- start running your python code
- start ngrok
- update facebook webhook with new ngrok URL
- Solution: heroku
- Online service that will create a url for you to host stuff
- set up is relatively easy
- Main advantage: you can just push updates to your python code to GitHub and they will automatically be deployed to your bot
- Its pretty easy to get a basic bot up and running
- Don't need to be super strong in Python, mainly copy and paste
- These bots are very basic but tons of room for creativity