<h1 align="center">
<a href="https://prompts.chat">

Sign in to like and favorite skills
Note Support for functions (aka plugins) is being added! Check out this discussion for more info and contribute!
A Telegram bot that integrates with OpenAI's official ChatGPT, DALL·E and Whisper APIs to provide answers. Ready to use with minimal configuration required.

/reset command/image command/stats command - by @AlexHTWOPENAI_MODEL parameter to gpt-4/setinline commandIf you'd like to help, check out the issues section and contribute!
If you want to help with translations, check out the Translations Manual
PRs are always welcome!
Customize the configuration by copying
.env.example and renaming it to .env, then editing the required parameters as desired:
| Parameter | Description |
|---|---|
| Your OpenAI API key, you can get it from here |
| Your Telegram bot's token, obtained using BotFather (see tutorial) |
| Telegram user IDs of admins. These users have access to special admin commands, information and no budget restrictions. Admin IDs don't have to be added to . Note: by default, no admin () |
| A comma-separated list of Telegram user IDs that are allowed to interact with the bot (use getidsbot to find your user ID). Note: by default, everyone is allowed () |
The following parameters are optional and can be set in the
.env file:
| Parameter | Description | Default value |
|---|---|---|
| Determines the time frame all budgets are applied to. Available periods: (resets budget every day), (resets budgets on the first of each month), (never resets budget). See the Budget Manual for more information | |
| A comma-separated list of $-amounts per user from list to set custom usage limit of OpenAI API costs for each. For - user lists the first value is given to every user. Note: by default, no limits for any user (). See the Budget Manual for more information | |
| $-amount as usage limit for all guest users. Guest users are users in group chats that are not in the list. Value is ignored if no usage limits are set in user budgets (=). See the Budget Manual for more information | |
| $-price per 1000 tokens used to compute cost information in usage statistics. Source: https://openai.com/pricing | |
| A comma-separated list with 3 elements of prices for the different image sizes: , and . Source: https://openai.com/pricing | |
| USD-price for one minute of audio transcription. Source: https://openai.com/pricing | |
Check out the Budget Manual for possible budget configurations.
| Parameter | Description | Default value |
|---|---|---|
| Whether to enable message quoting in private chats | |
| Whether to enable image generation via the command | |
| Whether to enable transcriptions of audio and video messages | |
| Proxy to be used for OpenAI and Telegram bot (e.g. ) | - |
| The OpenAI model to use for generating responses. You can find all available models here | |
| A system message that sets the tone and controls the behavior of the assistant | |
| Whether to show OpenAI token usage information after each response | |
| Whether to stream responses. Note: incompatible, if enabled, with higher than 1 | |
| Upper bound on how many tokens the ChatGPT API will return | for GPT-3, for GPT-4 |
| Max number of messages to keep in memory, after which the conversation will be summarised to avoid excessive token usage | |
| Maximum number of minutes a conversation should live since the last message, after which the conversation will be reset | |
| Whether to answer to voice messages with the transcript only or with a ChatGPT response of the transcript | |
| A semicolon separated list of phrases (i.e. ). If the transcript starts with any of them, it will be treated as a prompt even if is set to | - |
| Number of answers to generate for each input message. Note: setting this to a number higher than 1 will not work properly if is enabled | |
| Number between 0 and 2. Higher values will make the output more random | |
| Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far | |
| Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far | |
| The DALL·E generated image size. Allowed values: , or | |
| If set, the bot in group chats will only respond to messages that start with this keyword | - |
| If set to true, the bot will not process transcriptions in group chats | |
| Language of general bot messages. Currently available: , , , , , , , , , , , , , , . Contribute with additional translations | |
Check out the official API reference for more details.
Clone the repository and navigate to the project directory:
git clone https://github.com/n3d1117/chatgpt-telegram-bot.git cd chatgpt-telegram-bot
python -m venv venv
# For Linux or macOS: source venv/bin/activate # For Windows: venv\Scripts\activate
requirements.txt file:pip install -r requirements.txt
python bot/main.py
Run the following command to build and run the Docker image:
docker compose up
You can also use the Docker image from Docker Hub:
docker pull n3d1117/chatgpt-telegram-bot:latest docker run -it --env-file .env n3d1117/chatgpt-telegram-bot
or using the GitHub Container Registry:
docker pull ghcr.io/n3d1117/chatgpt-telegram-bot:latest docker run -it --env-file .env ghcr.io/n3d1117/chatgpt-telegram-bot
docker build -t chatgpt-telegram-bot . docker run -it --env-file .env chatgpt-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.