/olutbot

Telegram bot which helps to find beers from Alko

Primary LanguageJavaScriptMIT LicenseMIT

Olutbot - Telegram bot

This is my attempt to learn and try Telegram Bot API and how to connect it with other services. I have used carlo-colombo/serverless-telegram-bot-gc-functions to connect Telegram to Google Cloud.

I ended up selecting Algolia search for a backend to create an easy solution but basically any database which has some kind of search functionalities works the same way. If you want to use your own, just edit searchBeer and fetchAlko according to your needs.

Prerequisites

Set up

Create a google cloud profile and setup a cloud functions project with runtimeconfig enabled.

Edit config.js and add Botname, Google project and bucket name and Telegram token, Algolia tokens.

Run npm deployment script which will create telegram config, deploy olutbot and fetchAlko functions and sets up a webhook to telegram.

Testing

Local testing can be done with a local Cloud Functions emulator.

npm -g install @google-cloud/functions-emulator

functions start
functions deploy olutbot --trigger-http

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
     "message": {
       "chat": {
         "id": 123
       },
       "text": "Oispa kaljaa"
     }
   }' \
   http://localhost:8010/PROJECT_ID/us-central1/olutbot

# To tail logs
watch functions logs read