Skip to content

cccaaannn/telegram_chatgpt

Repository files navigation

Telegram ChatGPT

Message with ChatGPT on Telegram.

GitHub top language GitHub repo size GitHub GitHub release


Setup

Preliminary steps

  1. Get a Telegram bot key.
  2. Get a OpenAI api key.

Running

Docker

  1. Run the container.
docker run --name telegram_chatgpt -e TELEGRAM_BOT_KEY=<TELEGRAM_BOT_KEY> -e OPENAI_API_KEY=<OPENAI_API_KEY> cccaaannn/telegram_chatgpt:latest
  • You should map the db to outside, to keep the chat history after bot restarts.
docker run --name telegram_chatgpt -e TELEGRAM_BOT_KEY=<TELEGRAM_BOT_KEY> -e OPENAI_API_KEY=<OPENAI_API_KEY> -v <YOUR_DB_PATH>:/telegram_chatgpt/db cccaaannn/telegram_chatgpt:latest
  • Optionally you can map the logs to a directory.
docker run --name telegram_chatgpt -e TELEGRAM_BOT_KEY=<TELEGRAM_BOT_KEY> -e OPENAI_API_KEY=<OPENAI_API_KEY> -v <YOUR_DB_PATH>:/telegram_chatgpt/db -v <YOUR_LOG_PATH>:/telegram_chatgpt/logs cccaaannn/telegram_chatgpt:latest

Without docker

  1. Install dependencies.
pip install -r requirements.txt

2 Run by passing keys

python telegram_chatgpt -t <TELEGRAM_BOT_KEY> -o <OPENAI_API_KEY>

2 You can also set api keys as env variables to run without parameters

export TELEGRAM_BOT_KEY=<TELEGRAM_BOT_KEY>
export OPENAI_API_KEY=<OPENAI_API_KEY>
python telegram_chatgpt