ChatGPT provides free API and 18$ token for you to create Bot on Telegram. In this article, I will guide you to create a ChatGPT Bot on Telegram for free for you to chat or add to your Telegram group.
|Join the channel Telegram belong to AnonyViet ???? Link ????|
I find this topic hot forever. ChatGPT The more developed the software, the more afraid of software brothers, but that is for those who do not know how to exploit the power of ChatGPT. To take full advantage of ChatGPT, you must include it in your daily activities. One of the activities you do most often is to exchange messages on online application platforms such as messenger and telegram. Messenger, I have not heard of anyone integrating ChatGPT, but telegram does. So in this article, I will guide you to create a telgeram bot using ChatGPT extremely easily.
ChatGPT telegram bot feature
Support markdown in the answer
Reset the conversation using the /reset . command
Shows typing message while waiting for bot response
Access can be restricted by specifying a list of users
Docker and Proxy Support
Create an image using DALL·E via the /image . command
Transcribe audio and video messages using Whisper (may require ffmpeg)
Automatically summarize responses to avoid excessive API usage
Track API usage per user
Statistics for each individual’s API usage and cost per day/month via /stats . command
- Stream Support
To create ChatGPT Bot on Telegram, you should install it on Ubuntu or Kali Linux for better support.
- Python 3.9+
- Token bot Telegram. You can use BotFather here: Type command
/newbot, then enter a name for the Bot you want to create. Note, the Bot name must end with _BOT, for example:
ANVGPT_BOTafter creating you will see the botfather provides HTTP API, remember to save this token.
- OpenAI API. Register for an OpenAI ChatGPT account (instruct). Then copy the API Key at this page.
How to install
Step 1: Clone repo from github and access project folder from cmd.
git clone https://github.com/n3d1117/chatgpt-telegram-bot.git cd chatgpt-telegram-bot
Step 2: Create a virtual environment for python.
python -m venv venv
Step 3: Enable the virtual environment.
Step 4: Install other libraries in file requirements.txt:
pip3 install -r requirements.txt
Step 5: Replace OpenAI API and bot father in file
.env.example. Then rename this file to
In case you want to add bots to the telegram group, you can change the parameters ADMIN_USER_IDS and ALLOWED_TELEGRAM_USER_IDS.
- ADMIN_USER_IDS: Telegram ID of admin admin. These users have access to special commands, information, and no budget restrictions. You do not need to add an administrator ID to ALLOWED_TELEGRAM_USER_IDS. Note: by default the bot will have no admin (‘-‘).
- ALLOWED_TELEGRAM_USER_IDS: List of Telegram user IDs, allowed to interact with bots (you can use getidsbot to find your user IDs). In order for everyone to be able to chat with the bot, enter the *.
Step 6: Run the bot with the command below.
So that’s it then. Now you go to Telegram, find the bot you just created with Botfather and chat with it, it will get results from ChatGPT to reply to you.
In addition, the Bot supports the following commands:
- /image: create images from cue words
- /stats: statistics of tokens used by ChatGPT API
- /reset: delete the requested information stored on ChatGPT
- /help: show support panel
Advanced: Re-optimizing ChatGPT Bot on Telegram
In case you create a ChatGPT Bot into a telegram group, there is a point to note that normal messages will all be responded to by the bot. So it will be easy to encounter spam cases if your group is large. You can modify the following lines of code so that when the user uses the ask command, the bot will respond.
Step 1: First, you find the prompt function and rename this function to
ask. Just change the prompt to ask.
Step 2: In the newly renamed ask function, change the command line in the image to the command below:
prompt = update.message.text.replace('/ask', '').strip()
Step 3: Replace the handler function call with the following function:
So you have created your own ChatGPT Bot on Telegram, you can use it alone to add to the group so that it becomes your assistant by answering yourself with the results of AI GPT.