Skip to content

Your self-hosted telegram bot for chatting with ChatGPT

License

Notifications You must be signed in to change notification settings

clemsau/telegram-gpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

telegram-gpt

Your self-hosted telegram bot for chatting with ChatGPT.

Features

  • GPT-3.5 chatbot.
  • Handle voice messages
  • Message streaming
  • Toggleable answer on mentions, for a better integration in group chats.
Demo gif

Installation

  1. Set your environment variables

    ⚠ Note that ALLOWED_USERS is 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_USERS or 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:

    1. create a .env file in the /src folder 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.example file and rename it to .env.

    2. 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"
  2. Install the requirements

    pip install -r requirements.txt

Usage

Run the bot

python src/bot.py

Deployment

You 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).

Contributing

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.

License

MIT

About

Your self-hosted telegram bot for chatting with ChatGPT

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published