WFP mVAM food prices Telegram bot.
- A PostgreSQL database version
9.5, which can be provisioned via micrate and seeded via
- A Telegram bot, created by talking to BotFather
- A Wit.ai application
ffmpegis 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
To set up a Telegram bot to use for this project, talk to BotFather and run the following slash commands:
/newbotto create the bot, make sure to write down the access token
/setdescriptionto set a suitable welcoming message
/setinlineto enable inline mode, with a description like
/seteinlinegeoto send user GPS coordinates with inline queries
/setcommandswith the commands list
Bot commands list
/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
Set the following environment variables:
WFP_DATA_URL: URL to WFP dataset in CSV format, such as
TELEGRAM_TOKEN: access token for the Telegram bot
TELEGRAM_BOT_NAME: name of the bot, defaults to
PG_URL: URL to the postgres DB
In addition, if using the Telegram webhook to get updates, instead of polling:
TELEGRAM_WEBHOOK_URL: URL of the webhook where Telegram should post updates
TELEGRAM_CERTIFICATE_PATH: path to the certificate to set with the webhook
TELEGRAM_KEY_PATH: path to the private key of the certificate, if the app should listen for secure connections
TELEGRAM_BIND_ADDRESS: bind address for listening to Telegram updates
TELEGRAM_BIND_PORT: bind port for listening to Telegram updates
To run the web application:
WEB_USERNAME: user for basic-auth access
WEB_PASSWORD: pass for basic-auth access
WEB_BIND_ADDRESS: address for binding the web app
WEB_BIND_PORT: port for binding the web app
WEB_URL: public address where the web app is accessible
To forward all not-understood messages to wit.ai:
WIT_ACCESS_TOKEN: access token for wit.ai application
To enable geocoding for users location add either
MAPQUEST_ACCESS_TOKEN, depending on which service you wish to use.
Run locally with
A supporting web application can be run with
- Create test db with
- Run migrations
- Seed test DB running
- Run tests with
Overview 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.