WFP mVAM food prices Telegram bot.
9.5, which can be provisioned via micrate and seeded via bin/load-prices.ffmpeg is needed for voice messages recognition (can be installed on Mac using Homebrew)To create a development database and run migrations:
$ createdb -E utf8 -O `whoami` mvam-chatbot
$ bin/micrate up
Prices can be seeded by running bin/load-prices
To set up a Telegram bot to use for this project, talk to BotFather and run the following slash commands:
/newbot to create the bot, make sure to write down the access token/setdescription to set a suitable welcoming message/setinline to enable inline mode, with a description like search prices.../seteinlinegeo to send user GPS coordinates with inline queries/setcommands with the commands listUpon sending /setcommands to BotFather, send:
location - Set your location
price - Get prices on a commodity near you
help - Detailed help on this bot
To create a sample certificate to use in Telegram serve mode:
openssl req -newkey rsa:2048 -sha256 -nodes -keyout cert.key -x509 -days 365 -out cert.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=cert"
An application that should be able to identify the required entities and intents.
Several entities can be seeded with all the WFP DB prices by running bin/upload-entities.
Set the following environment variables:
WFP_DATA_URL: URL to WFP dataset in CSV format, such as http://vam.wfp.org/sites/data/WFPVAM_FoodPrices_18-05-2016.csvTELEGRAM_TOKEN: access token for the Telegram botTELEGRAM_BOT_NAME: name of the bot, defaults to wfpBotPG_URL: URL to the postgres DBIn addition, if using the Telegram webhook to get updates, instead of polling:
TELEGRAM_WEBHOOK_URL: URL of the webhook where Telegram should post updatesTELEGRAM_CERTIFICATE_PATH: path to the certificate to set with the webhookTELEGRAM_KEY_PATH: path to the private key of the certificate, if the app should listen for secure connectionsTELEGRAM_BIND_ADDRESS: bind address for listening to Telegram updatesTELEGRAM_BIND_PORT: bind port for listening to Telegram updatesTo run the web application:
WEB_USERNAME: user for basic-auth accessWEB_PASSWORD: pass for basic-auth accessWEB_BIND_ADDRESS: address for binding the web appWEB_BIND_PORT: port for binding the web appWEB_URL: public address where the web app is accessibleTo forward all not-understood messages to wit.ai:
WIT_ACCESS_TOKEN: access token for wit.ai applicationTo enable geocoding for users location add either MAPZEN_ACCESS_TOKEN or MAPQUEST_ACCESS_TOKEN, depending on which service you wish to use.
Run locally with crystal src/mvam-bot.cr.
A supporting web application can be run with crystal src/mvam-web.cr.
createdb mvambot-testbin/micrate up with PG_URL=postgres://ubuntu@localhost/mvambot-testbin/load-prices with PG_URL=postgres://ubuntu@localhost/mvambot-testcrystal specOverview of upcoming milestones.
Support for geolocated price queries via inline queries, commands, or NLP. Use WFP food prices DB to answer queries.
Run food security surveys from the bot.
Await feedback from the two previous milestones and implement suggested changes.
Content type
Image
Digest
Size
197.6 MB
Last updated
over 9 years ago
docker pull instedd/mvam-chatbot:facebook_messenger