- Create the Telegram bot via BotFather
- Create the Google api keys
- Configure the bot backend
- How it works
The official description of creation
In two words:
- Go to the https://t.me/BotFather bot
- Start with the
/newbot
command and follow the instructions - Copy and save the token as the
TELEGRAM_BOT_TOKEN=
variable in the.env
file
Slightly complicated that Telegram bot but let's do some stuff. This bot uses the Google spreadsheet npm library. It has a good authentication tutorials. You need to do 2 things
- Follow the instructions in the Service Account (recommended)
- Save the
creds.json
from the Google in the bot root directory
There are two variants of running the bot.
Pull repo
->cp env.template .env
->download creds.json from google and place somewhere in your disc
->npm ic
->npm run start
- Use the docker run command below:
!!! pass the Google's creds.json file into command
docker run \
-e TELEGRAM_BOT_TOKEN='your-telegram-bot-token' \
-e ALLOWED_TELEGRAM_IDS='0000000,00000000' \
-e GOOGLE_SHEET_ID='your-google-document-id' \
-e LANGUAGE='en' \
-e GOOGLE_CREDS_PATH='/usr/src/app/creds/creds.json' \
-v path/to/creds_json/directory:/usr/src/app/creds
xenmayer/geek-expenses-telegram-bot:latest
It's suggested to start with the GoogleSpreadsheet document with list named e.g. empty
.
Once when the bot is starts by the docker run
or the npm run start
. It opens the GoogleSpreadsheet file and tries to find the YEAR named list, for instance 2021
. If it does, it is just starts serving the bot and waiting for commands. If it doesn't, it creates such list and adds basic expenses spreadsheed template.
The bot has one command /store
shows the expenses categories selection menu.
After selection of the category it waits the amount message. And adds the value to the required cell in the GoogleSpreadsheet file.