Skip to content

Latest commit

 

History

History
75 lines (49 loc) · 3.07 KB

README.md

File metadata and controls

75 lines (49 loc) · 3.07 KB

Geek Expenses (works fine, but in the active developing phase now)

The Telegram bot with the GoogleSpreadsheet database

Steps to deploy your own expense tracking bot

  1. Create the Telegram bot via BotFather
  2. Create the Google api keys
  3. Configure the bot backend
  4. How it works

1 Create the Telegram bot via BotFather

The official description of creation

In two words:

  1. Go to the https://t.me/BotFather bot
  2. Start with the /newbot command and follow the instructions
  3. Copy and save the token as the TELEGRAM_BOT_TOKEN= variable in the .env file

2 Create Google Api keys

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

  1. Follow the instructions in the Service Account (recommended)
  2. Save the creds.json from the Google in the bot root directory

3 Configure the bot backend

There are two variants of running the bot.

  1. Pull repo -> cp env.template .env -> download creds.json from google and place somewhere in your disc -> npm ic -> npm run start
  2. 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

The DockerHub package page

4 How it works

It's suggested to start with the GoogleSpreadsheet document with list named e.g. empty.

image

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.

image

The bot has one command /store shows the expenses categories selection menu.

image

After selection of the category it waits the amount message. And adds the value to the required cell in the GoogleSpreadsheet file.

image

image