Your self-hosted telegram bot for chatting with ChatGPT.
- GPT-3.5 chatbot.
- Handle voice messages
- Message streaming
- Toggleable answer on mentions, for a better integration in group chats.
-
Set your environment variables
⚠ Note that
ALLOWED_USERSis for the user IDs and not the usernames. To get your user ID, you can use @userinfobot on telegram.⚠ If you don't set any
ALLOWED_USERSor set it to an empty string, everyone will be able to use your bot. Be aware that it might cause unexpected usage of your API key and costs.You have multiple options:
-
create a
.envfile in the/srcfolder with the following content:TELEGRAM_TOKEN="your_telegram_token" OPENAI_API_KEY="your_openai_api_key" ALLOWED_USERS="allowed_user1,allowed_user2"
You can also fill the
.env.examplefile and rename it to.env. -
set the environment variables in your shell:
export OPENAI_API_KEY="your_telegram_token" export TELEGRAM_TOKEN="your_openai_api_key" export ALLOWED_USERS="allowed_user1,allowed_user2"
-
-
Install the requirements
pip install -r requirements.txt
Run the bot
python src/bot.pyYou have multiple solutions to deploy this bot. The simplest solution is to run it on a bare metal server. Since this application run on very low resources, you can run it on a raspberry pi or a small vps (e.g: Digital Ocean 4$/month droplet).
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change
Try to be as descriptive as possible when opening an issue.
