This is a Node.js-based Telegram Bot application that leverages OpenAI's API Key to interface with ChatGPT and retrieve responses. This bot is equipped with the following functionalities:
- Send a message to the Telegram bot and get a response from ChatGPT
- Retention of conversation history in memory via ChatGPT, providing continuity to previous discussion threads
- Option to reset conversation history by executing the
/reset
command for a new, refreshed interaction with ChatGPT. - Telegram user IDs whitelist to prevent abuse (Optional)
- Clone the repository
- Run
yarn install
- Copy
.env.example
to.env
and fill in the required values - Run
yarn start
Environment variable | Description |
---|---|
TELEGRAM_TOKEN |
Obtain a Telegram bot token from BotFather using the /newbot command |
CHATGPT_TOKEN |
Obtain an OpenAI API Key from the API Keys |
ONLY_ALLOW_WHITELISTED_TELEGRAM_IDS |
Set to true to only allow whitelisted Telegram IDs to use the bot |
WHITELISTED_TELEGRAM_IDS |
A comma-separated list of Telegram IDs to allow to use the bot. You can obtain user IDs by forwarding messages to userinfobot. This variable is required if ONLY_ALLOW_WHITELISTED_TELEGRAM_IDS is set to true . |
- You can build the Docker image for this project by running
docker build -t chatgpt-telegram-bot .
- During container deployment, set the environment variables as defined in the
.env.example
file.