A Telegram bot that integrates with OpenAI's ChatGPT to provide answers. Ready to use with minimal configuration required. Based on acheong08/ChatGPT
- Reply to specific messages
- Support markdown in answers
- Can reset conversation thread with the
/reset
command - Typing indicator while generating a response
- Access can be restricted by specifying a list of allowed users
- Multi-chat support
- Idea: cache different instances of
ChatGPT3Bot
, one for every chat id (maybe even persist them), so that every user has their own private conversation
- Idea: cache different instances of
- Support group chats
- Allow the bot to be used in group chats with specific commands
- Docker support
- With
Dockerfile
anddocker-compose.yml
. See pull/2 for a start
- With
- Advanced commands
- With premade ad-hoc prompts
- Token based authentication
- As an alternative to email/password authentication for those who signed up with other services (Google/Microsoft) or for those who get a
Captcha detected
error, see #13
- As an alternative to email/password authentication for those who signed up with other services (Google/Microsoft) or for those who get a
PRs are always welcome!
- Python 3.10+ and Pipenv
- A Telegram bot and its token (see tutorial)
- An OpenAI account (see configuration section)
- Clone the repository and navigate to the project directory:
git clone https://github.com/n3d1117/chatgpt-telegram-bot.git
cd chatgpt-telegram-bot
- Create a new virtual environment with Pipenv and install the required dependencies:
pipenv install
- Activate the virtual environment:
pipenv shell
Customize the configuration by copying .env.example
and renaming it to .env
, then editing the settings as desired:
OPENAI_EMAIL="<YOUR_OPENAI_EMAIL>"
OPENAI_PASSWORD="<YOUR_OPENAI_PASSWORD>"
TELEGRAM_BOT_TOKEN="<YOUR_TELEGRAM_BOT_TOKEN>"
OPENAI_EMAIL,OPENAI_PASSWORD
: Your OpenAI credentials (these are only sent to the OpenAI server to periodically refresh the access token and never shared). You can read more about it hereTELEGRAM_BOT_TOKEN
: Your Telegram bot's token, obtained using BotFather (see tutorial)
Additional optional (but recommended) configuration values:
ALLOWED_TELEGRAM_USER_IDS="<USER_ID_1>,<USER_ID_2>,..." # Defaults to "*"
PROXY="<HTTP/HTTPS_PROXY>" # E.g. "http://localhost:8080", defaults to none
DEBUG=false # Defaults to true
ALLOWED_TELEGRAM_USER_IDS
: A comma-separated list of Telegram user IDs that are allowed to interact with the bot (use getidsbot to find your user ID). Important: by default, everyone is allowed (*
)PROXY
: Proxy to be used when authenticating with OpenAIDEBUG
: Enable debug logging for the revChatGpt package
Use the following command to start the bot:
python main.py
- ChatGPT from OpenAI
- acheong08/ChatGPT for reverse engineering ChatGPT APIs
- rawandahmad698/PyChatGPT for his work on the authentication protocol
- python-telegram-bot
This is a personal project and is not affiliated with OpenAI in any way.
This project is released under the terms of the GPL 2.0 license. For more information, see the LICENSE file included in the repository.