-
Notifications
You must be signed in to change notification settings - Fork 12
Messaging platforms
Matúš Žilinec edited this page Jun 23, 2018
·
3 revisions
Golem provides integrations for the most widely used chat platforms. Additionally, it is extensible and you can provide your own endpoint if needed. (Contributions are welcome!)
Facebook sends an HTTP request each time there is a new message. For this to work, you need a public IP address. If you don't have one, we recommend using ngrok. You can start it like this:
ngrok http 8000 # will forward port 8000 to a subdomain of ngrok.io
You will need:
- a Facebook page - your users will message it and the chatbot will reply
- a Facebook application - responsible for connecting Messenger to your chatbot
- Create an app @ https://developers.facebook.com/apps.
- Under Products, activate Messenger, generate an access token for your page and add it to
settings.py
. Then click Edit events, checkmessages
andmessaging_postbacks
and subscribe your bot to the page. - Open
golem_settings.py
and add the following toGOLEM_CONFIG
:
-
FB_PAGE_TOKEN
: the access token from step 1 -
WEBHOOK_VERIFY_TOKEN
: (any) password used by Facebook to verify it's your bot -
WEBHOOK_SECRET_URL
: (any) secret URL used to hide the endpoint
- Start the chatbot.
- In FB's console, under Products, activate Webhooks, select your Page from the dropdown, click Edit Subscription and set your endpoint URL in format
https://xxx.ngrok.io/chatbot/messenger/SECRET_URL/
. The verify token must match the one in your settings. - Try sending a message to your page. It should now get through to your bot.
# golem_settings.py
GOLEM_CONFIG = {
...
'FB_PAGE_TOKEN': 'THE_TOKEN_YOU_GOT_FROM_FACEBOOK',
'WEBHOOK_SECRET_URL': 'my_secret_url', # used to hide endpoint url from 3rd party
'WEBHOOK_VERIFY_TOKEN': 'my_password', # used by FB to verify it's you
...
We recommend using os.environ.get("VARIABLE")
to avoid committing your secret codes to version control.
TODO
TODO