A simple Telegram bot example that integrates with OpenAI's ChatGPT with minimal configuration required.
- run locally using
main
branch, or - deploy to any online server as a Flask app using
telebot2
branch - added GPT-4-Turbo and GPT-4-Vision models!
- Python 3.9+
- A Telegram bot and its token (see tutorial)
- An OpenAI account (see configuration section)
Customize the configuration by copying .env.example
and renaming it to .env
, then editing the required parameters as desired:
Parameter | Description |
---|---|
OPENAI_API_TOKEN |
Your OpenAI API key from here |
TELEGRAM_API_TOKEN |
Your Telegram bot's token, obtained using BotFather (see tutorial) |
TELEGRAM_BOT_NAME |
Your Telegram bot's name |
PUBLIC_URL |
Web service provider's URL for your app e.g. https://www.yourapp-heroku.com (only for telebot2 branch) |
Clone the repository and navigate to the project directory:
git clone https://github.com/reedemus/teleGPT.git
cd teleGPT
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
# For Linux or macOS:
source venv/bin/activate
# For Windows:
venv\Scripts\activate
To deploy bot online, skip to Deploy to web host section.
- Install the dependencies using
requirements.txt
file:
pip install -r requirements.txt
- Checkout
main
branch
git checkout main
- Use the following command to start the bot:
python app.py
- Install the dependencies using
requirements.txt
file:
pip install -r requirements.txt
- Checkout
telebot2
branch
git checkout telebot2
- Use the following command to start the bot The bot is deployed as a Flask app with gunicorn wsgi server with the command below:
gunicorn wsgi:app
This is a personal project and is not affiliated with OpenAI or StabilityAI in any way.
This project is released under the terms of the MIT license. For more information, see the LICENSE file included in the repository.