This repository contains two projects: Connector-Service and Bot-Service.
- TELEGRAM_TOKEN: Telegram API token.
- BOT_SERVICE_URL: URL of the Bot-Service.
Build
npm install
npm install typescript
npx tsc
Run
node dist/app.js
- /telegram-id: Returns the user's telegram_id.
- /list-expenses: Lists the expenses made by the user.
- Any other instruction will be assumed as an expense, which will be processed and categorized. If it's not an expense, the message will be ignored.
- OPEN_API_API_KEY: API key for Open API.
- DB_HOST: Database host.
- DB_PORT: Database port.
- DB_USER: Database username.
- DB_PASSWORD: Database password.
- DB_NAME: Database name.
Install dependencies
pip install -r requirements.txt
Run
python3 src/app.py
-
POST
/api/telegram-users/{telegram-id}
Registers a user associated with the telegramId. -
GET
/api/telegram-users/{telegram-id}/expenses
Lists all expenses of the user in JSON format:
{
"expenses": [
{
"added_at": "Sat, 25 May 2024 18:23:55 GMT",
"amount": 2.0,
"category": "FOOD",
"description": "McDonalds"
},
{
"added_at": "Mon, 27 May 2024 03:01:39 GMT",
"amount": 60.0,
"category": "ENTERTAINMENT",
"description": "The Legend of Zelda Breath Of The Wild"
}
]
}
- POST
/api/telegram-users/{telegram-id}/expenses
Receives JSON with a 'message' field containing the expense description, e.g., "Pizza, 20 bucks." The bot responds with the categorized expense in the following format:
Request
{
"message": "Pizza, 20 bucks."
}
Response
{
"added_at": "Mon, 27 May 2024 20:46:43 GMT",
"amount": 20.0,
"category": "FOOD",
"description": "Pizza"
}
If the message is not an expense, it returns a bad request (400), if the user does not exists unauthorized (401).