This repository contains the source code for a Telegram bot that leverages DocsGPT to provide intelligent responses to user queries. This bot is an extension for DocsGPT.
- Responds to user queries with intelligent answers using DocsGPT.
- Maintains conversation history for context-aware responses.
- Supports multiple storage backends for conversation history (in-memory or MongoDB).
- Easily deployable using Docker.
Before you begin, ensure you have met the following requirements:
- You have registered a bot with BotFather on Telegram and obtained a
TOKEN
. - You have created an API key on DocsGPT to access your AI's data and prompt.
-
Clone the repository:
git clone https://github.com/arc53/tg-bot-docsgpt-extenstion.git cd tg-bot-docsgpt-extenstion
-
Set up a virtual environment:
python3 -m venv venv
- On macOS and Linux:
source venv/bin/activate
- On Windows:
.\venv\Scripts\activate
- On macOS and Linux:
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the project directory and add your environment variables:TELEGRAM_BOT_TOKEN=<your-telegram-bot-token> API_KEY=<your-api-key> # Optional: Storage Configuration (Defaults to in-memory) # STORAGE_TYPE=mongodb # MONGODB_URI=<your-mongodb-connection-string> # MONGODB_DB_NAME=telegram_bot_memory # MONGODB_COLLECTION_NAME=chat_histories
TELEGRAM_BOT_TOKEN
: Your Telegram bot token from BotFather.API_KEY
: Your DocsGPT API key.STORAGE_TYPE
: (Optional) Specifies where to store conversation history. Defaults tomemory
. Set tomongodb
to use MongoDB.MONGODB_URI
: (Required ifSTORAGE_TYPE=mongodb
) Your MongoDB connection string.MONGODB_DB_NAME
: (Optional, defaults totelegram_bot_memory
) The name of the MongoDB database.MONGODB_COLLECTION_NAME
: (Optional, defaults tochat_histories
) The name of the MongoDB collection.
-
Run the bot:
python bot.py
-
Clone the repository:
git clone https://github.com/arc53/tg-bot-docsgpt-extenstion.git cd tg-bot-docsgpt-extenstion
-
Build the Docker image:
docker build -t telegram-gpt-bot .
-
Create a
.env
file in the project directory and add your environment variables:TELEGRAM_BOT_TOKEN=<your-telegram-bot-token> API_KEY=<your-api-key> # Optional: Storage Configuration (Defaults to in-memory) # STORAGE_TYPE=mongodb # MONGODB_URI=<your-mongodb-connection-string> # MONGODB_DB_NAME=telegram_bot_memory # MONGODB_COLLECTION_NAME=chat_histories
See the Python installation section above for details on environment variables.
-
Run the Docker container:
docker run --env-file .env telegram-gpt-bot
/start
- Initiates the conversation with the bot./help
- Provides help information.
Simply type any message, and the bot will respond with an intelligent answer based on the context of the conversation maintained in context.chat_data
.
bot.py
: The main script for running the bot.requirements.txt
: Python dependencies required by the bot.Dockerfile
: Instructions to build the Docker image.docker-compose.yml
: Docker Compose configuration for easier deployment..env
: File containing environment variables (not included, must be created).
This project is licensed under the MIT License - see the LICENSE file for details.