We adjusted configuration format since v1.4.0, which is NOT compatible with previous versions. Please check the config doc for more details. You should backup your old config file and create a new one after updating to v1.4.0.
config.py
configuration script.ChatGPT Bot for Telegram is implemented with OpenAI ChatGPT API released on March 1, 2023. The Telegram integration framework is based on python-telegram-bot.
ChatGPT Bot can act as your Telegram contact. You can chat with it personally, share with a contact, and collabrate in a group chat. We attach great importance to privacy protection and make sure the Bot can't acquire any unrelated messages in group chats.
The Bot shares knowledge and inspires exciting new ideas. Many interesting features, such as DALL·E and Whisper are integrated together to make our Bot smarter and more usable.
We hope you enjoy it!
The Telegram Bot features the following functions:
Additonal features:
allow_all_users
to true
to allow any users to use the Bot.enable_voice
in the config file to False.git clone https://github.com/flynnoct/chatgpt-telegram-bot.git
cd chatgpt-telegram-bot
pip install -r requirements.txt
The config file includes sensitive information, such as telegram_token and openai_api_key, and we only release the corresponding template config.json.template
. Therefore, you need to create a new config.json
file by replacing the relative fields in the template with your own.
cp config.json.template config.json
Recommended: You should keep config.json.template
unmodified because the Bot needs to read default configuration values from it. For backward compatibility, it is highly recommended to check the template for newly added parameters when you update to a new version.
For more details, see documentation.
start_bot.sh
and try talk to it. You can also use docker to run the Bot.# First, make sure you are in the root directory of the project,
# aka <your_download_location>/chatgpt-telegram-bot
bash ./bin/start_bot.sh # start the Bot
# Use docker compose to run the Bot
docker compose up -d
To clear ChatGPT conversation context and restart the Bot, run shell script restart_bot.sh
. To shut down the Bot, run stop_bot.sh
.
bash ./bin/restart_bot.sh # restart the Bot
bash ./bin/stop_bot.sh # stop the Bot
Up to now, you have successfully deployed the Bot.
The Bot works in both personal and group chat of Telegram.
In a personal chat, simply send a message to the Bot and it will reply to you.
In a group chat, use the /chat
to invoke the Bot.
In a personal chat with a contact, use @your_bot_name <your messages>
to invoke the Bot with Telegram inline mode. Both you and your contact can see the Bot's reply in the chat.
/start
: Start the Bot./role <prompt>
: Set role for conversation./chat
: Invoke the Bot in group chat./dalle <prompt>
: Ask DALL·E for a painting based on your prompt./clear
: Clear the conversation context./getid
: Get your Telegram user ID.(Optinal) You can set them up as Telegram Bot command, see here.
To enable inline mode, see here.
Type /mybots
> Your_Bot_Name > Bot Settings > Inline Feedback, you must set the Inline Feedback
to 100%.
See documentation.
Documentation is provided under docs for developers who wants to customize the Bot.
The latest released version is here.
The release notes are here.
More interesting new features are coming soon!
If you like this project, you can buy me a coffee ❤️ or give this repository a free star ⭐️.
Click Alipay to open QR code.