Installing the bot
Facebook Bot Setup
The Ushahidi facebook-bot is built with Lumen and a mysql database. To set it up you need to
Prerequisites
Make sure you have the following installed:
You must have an instance of the COMRADES Platform deployed and accessible via the internet, as you will need to point the facebook bot to your deployment.
Set-up
Clone the repo: https://github.com/ushahidi/platform-facebook-bot
Create a .env file. An example-file is found in .env.example
The script
Bot uses a predefined script when talking to the users. It is not possible to adjust the questions themselves without doing some coding, but during setup, some information about the ushahidi-deployment and the campaign is needed. That information is added in the .env file and is used to create and adjust this script to the organisation using the bot. These are:
TITLE: The title of the Ushahidi-deployment connected to the the bot is used
AIM: The aim/a short description of the campign where the bot is used.
NAME: The name of the bot
TWITTER_NAME: The twitter-name for the organisation/campaign using the bot
TWITTER_HASH: The hashtag used for the organisation/campaign
The full script of the bot can be found here.
Credentials
For some of the credentials in the .env-file you need to create a “Facebook-app”. You do that here: https://developers.facebook.com.
After creating the app, select “Messenger” under “Add a product” in your app-settings:
In order to get an access-token, you need to connect it to a facebook-page. If you don’t have one already, go to the “normal” facebook (not the developer-one) and create a page:
After that, go back to developer-facebook and your app, in the messenger-settings, you can select your page and generate an access-token:
Add the access-token to your .env file together with a verify-token of your choice and the facebook secret token found here:
When all those credentials are in your .env-file, together with the credentials for the Ushahidi-deployment you want to use to send reports with, you start the application with
vagrant up and then
artisan php migrate --seed (this sets together the script for the bot, using the variables you added to the .env-file)
Now go back to developers.facebook.com and click on Messenger->settings to set up your webhooks.
Use your-url/webhook as callback-url and verify-token is the same as you choose in the .env file. Select messages and messaging_postbacks. Click on verify and save.
Go to your page and send a message to the page to start talking to the bot. It is good to add a start-button and a persistent-menu, instructions for those could be found in the facebook-documentation:
https://developers.facebook.com/docs/messenger-platform/send-messages/persistent-menu