This repository contains a Telegram bot called GastappBot that interacts with an expense management system. The bot allows users to ask questions about their expenses and receives progressive responses, mimicking a more conversational flow.
- Expense Management: You can easily query details about your expenses.
- Progressive Responses: The bot simulates an interactive conversation by showing responses in real-time, with the bot "typing..." during the conversation.
- External API Integration: The bot generates responses from an API configured in a JSON file.
Make sure you have the following installed:
- Python 3.11+
- Required libraries:
gspread
oauth2client
pandas
typer
python-telegram-bot
openai-whisper
ffmpeg-python
-
Clone the repository:
git clone https://github.com/yourusername/gastappbot.git cd gastappbot
-
Create a virtual environment and install dependencies:
conda create --name [NAME] python=3.11 conda activate [NAME]
-
Install the dependencies:
pip install -r requirements.txt
-
API Keys:
Createapi_credentials.json
file in thecredentials/
folder with the following format:{ "openrouter_key": "your_api_key", "telegram": "your_bot_key", "spreadsheet_id": "your_spreadsheet_id" }
-
Spreadsheet credentials:
Createcredentials.json
file in thecredentials/
folder (see info). -
Specify your personal configuration:
Update theconfig.json
file in the root directory with your specific configuration details. The file should include the following fields:sheet_data_name
: The name of the sheet in your spreadsheet where the data is stored.prompt_model
: The path to the prompt generation class.voice
: The path to the voice-to-text processing class.openrouter_models
: A list of models to be used by the bot.question
: The template for formatting questions.prompt
: The template for generating the prompt used by the bot.
Example
config.json
:{ "sheet_data_name": "Datos", "prompt_model": "prompt.prompt.MyPrompt", "voice": "voice.voicetotext.WhisperVoiceToText", "openrouter_models": [ {"name": "deepseek/deepseek-r1:free"}, {"name": "deepseek/deepseek-chat:free"} ], "question": "Pregunta: {question}.", "prompt": "..." }
You can create new voice models, NLP models, and prompts in the corresponding folders and use them by modifying the
config.json
file.
-
Set up the Telegram Bot:
Create a bot on Telegram using BotFather and get your token (update theapi_credentials.json
file). -
Update the data:
python update_data.py
-
Run the bot:
To start the bot, run the following command:python telegram_bot.py
-
Interact with the bot:
On Telegram, search for your bot and start chatting with it by asking questions related to your expenses.
The repository contains the following folders and files:
/gastappbot
├── /constants # Folder for the constants
└── constants.py
├── /prompt # Folder for prompt engineering
├── data.py
└── prompt.py
├── /nlp # Folder for nlp processing
├── models.py
└── nlp.py
├── /voice # Folder for voice processing
└── voicetotext.py
├── telegram_bot.py # Main script for the Telegram bot
├── update_data.py # Script to update the data
├── utils.py # Some utils functions
├── config.json # Configuration file
├── requirements.txt # Project dependencies
├── LICENSE # License
└── README.md # This documentation file
- Fork the repository.
- Create a branch (
git checkout -b new-feature
). - Make your changes and commit (
git commit -am 'Add new feature'
). - Push your changes (
git push origin new-feature
). - Open a pull request.
This project is licensed under the GPL License. See the LICENSE file for details.