Skip to content

jarumil/gastappbot

Repository files navigation

GastappBot: Telegram Bot for Expense Management

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.


🚀 Features

  • 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.

🛠️ Requirements

Make sure you have the following installed:

  • Python 3.11+
  • Required libraries:
    • gspread
    • oauth2client
    • pandas
    • typer
    • python-telegram-bot
    • openai-whisper
    • ffmpeg-python

⚙️ Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/gastappbot.git
    cd gastappbot
  2. Create a virtual environment and install dependencies:

    conda create --name [NAME] python=3.11
    conda activate [NAME]
  3. Install the dependencies:

    pip install -r requirements.txt

🔑 Configuration

  1. API Keys:
    Create api_credentials.json file in the credentials/ folder with the following format:

    {
      "openrouter_key": "your_api_key",
      "telegram": "your_bot_key",
      "spreadsheet_id": "your_spreadsheet_id"
    }
  2. Spreadsheet credentials:
    Create credentials.json file in the credentials/ folder (see info).

  3. Specify your personal configuration:
    Update the config.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.


📝 Usage

  1. Set up the Telegram Bot:
    Create a bot on Telegram using BotFather and get your token (update the api_credentials.json file).

  2. Update the data:

    python update_data.py
  3. Run the bot:
    To start the bot, run the following command:

    python telegram_bot.py
  4. Interact with the bot:
    On Telegram, search for your bot and start chatting with it by asking questions related to your expenses.


📚 Project Structure

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

🧑‍🤝‍🧑 Contributing

  1. Fork the repository.
  2. Create a branch (git checkout -b new-feature).
  3. Make your changes and commit (git commit -am 'Add new feature').
  4. Push your changes (git push origin new-feature).
  5. Open a pull request.

📄 License

This project is licensed under the GPL License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages