A simple yet powerful AI-based Telegram bot built using Pyrogram and DuckChat. This bot responds to user queries via the /ai
command and streams the response in real-time using the GPT-4o mini model.
- /start command: Welcomes users and explains how to use the bot.
- /ai command: Allows users to ask questions, and the bot will reply using AI-powered responses.
- Real-time response streaming: Users see the answer to their queries updated as the response is processed.
- Python 3.12
- A Telegram bot API token from BotFather
- DuckChat library from github.com/lunaticsm/duck_chat
-
Clone the repository:
git clone https://github.com/lunaticsm/Chatbot-Telegram-AI-Bot.git cd chatbot
-
Create a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.env
file in the root directory and add your credentials:API_ID=your_api_id API_HASH=your_api_hash BOT_TOKEN=your_bot_token
-
Run the bot:
python3 -m chatbot
-
Clone the repository: Open a terminal (CMD, PowerShell, or Git Bash) and run:
git clone https://github.com/lunaticsm/Chatbot-Telegram-AI-Bot.git cd chatbot
-
Create a virtual environment:
python -m venv venv venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.env
file in the root directory and add your credentials:API_ID=your_api_id API_HASH=your_api_hash BOT_TOKEN=your_bot_token
-
Run the bot:
python -m chatbot
-
Clone the repository:
git clone https://github.com/lunaticsm/Chatbot-Telegram-AI-Bot.git cd chatbot
-
Create a
requirements.txt
andProcfile
: Ensure your repository contains arequirements.txt
and aProcfile
.Procfile:
worker: python -m chatbot
-
Deploy to Heroku:
heroku create git push heroku main
-
Set up environment variables on Heroku:
heroku config:set API_ID=your_api_id heroku config:set API_HASH=your_api_hash heroku config:set BOT_TOKEN=your_bot_token
-
Run the bot: Heroku will automatically run the bot after deployment.
Create a requirements.txt
file with the following content:
pyrogram
python-dotenv
git+https://github.com/lunaticsm/duck_chat
This includes Pyrogram, dotenv for environment variable management, and DuckChat library from GitHub.
If you need assistance or have any questions, feel free to reach out on Telegram: @alterbase2.
This project is licensed under the MIT License.