A Telegram bot that uses OpenAI's GPT-3 to generate messages based on the context of the conversation.
- Create a Telegram bot with BotFather
- Create an OpenAI account and get an API key
- Set your keys in the
.envfile or as environment variables - Start the bot
- Send a message to the bot or add it to a group chat
- type
/to see the list of commands
-
Install dependencies
yarn
-
Configuration
Create a
.envfile or set env variables:TELEGRAM_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx OPENAI_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Optional: MONGO_URI=mongodb://localhost:27017 MONGO_DB=telegram-gpt CONTEXT_HISTORY_MAX_LENGTH=10
-
Start the bot
yarn start
version: '3' services: telegram-gpt: image: ghcr.io/mathieu2301/telegram-gpt:latest restart: always environment: TELEGRAM_KEY: ${TELEGRAM_KEY} OPENAI_KEY: ${OPENAI_KEY} # Optional: CONTEXT_HISTORY_MAX_LENGTH: 10 # You can use MongoDB as a database, otherwise # the contexts will be stored in a folder. # Remove this if you don't want to use MongoDB. MONGO_URI: ${MONGO_URI} MONGO_DB: telegram-gpt # Remove this if you use MongoDB volumes: - contexts:/app/contexts # Remove this if you use MongoDB volumes: contexts: