A ChatGPT bot for Telegram based on Node.js. Works with Cloudflare protection. Replace ChatGPT API to 4.1.1 which use official chatGPT api.
Private Chat | Group Chat |
---|---|
- Support for both private and group chats
- Work in privacy mode (the bot can only see specific messages)
- Bot access control based on user and group IDs
- Reset chat thread and refresh session with command
- Typing indicator, Markdown formatting, ...
- Cloudflare bypassing and CAPTCHA automation
- User-friendly logging
Note This bot uses a browser-based ChatGPT API, please make sure you have Node.js >= 18
and a Chromium-based browser installed.
To get started, follow these steps:
- Make a copy of the file
.env.example
and rename it as.env
. In the.env
file, enter your OpenAI account information and Telegram bot token. SetIS_GOOGLE_LOGIN
totrue
if you're using Google auth.- Specify the ID of the users and groups who are permitted to use this bot. Separate multiple IDs with commas (
,
). Note that all members of the specified groups will have access to the bot inside the group. If you leave these options empty, every person and group will be able to use the bot. If the browser is not installed in the default location, specify its executable path. You can also specify proxy settings, if needed.Specify theNOPECHA_KEY
orCAPTCHA_TOKEN
if you're using the corresponding CAPTCHA solver.- You can also specify the command to invoke the bot in group chats. The default command is
/chat
. SetIS_PRO_ACCOUNT
totrue
if you're using a premium / pro / paid account.- Specify the
OPENAI_API_KEY
of your openai platform account.
Then you can start the bot with:
pnpm install
pnpm build && pnpm start
To chat with the bot in Telegram, you can:
- Send direct messages to the bot (this is not supported in groups)
- Send messages that start with the specified command (e.g.,
/chat
or the command you specified in the.env
file) - Reply to the bot's last message
Note Make sure you have enabled the privacy mode of your bot before adding it to a group, or it will reply to every message in the group.
The bot also has several commands.
/help
: Show help information./reset
: Reset the current chat thread and start a new one./reload
(admin required): Refresh the ChatGPT session.
Note When using a command in a group, make sure to include a mention after the command, like
/help@chatgpt_bot
.
No need browser session now.
You can also try this docker image by running the following command from the project root folder:
docker compose up
- ChatGPT API: Node.js client for the unofficial ChatGPT API.
- Node.js Telegram Bot API: Telegram Bot API for NodeJS.
- 🤖️ chatbot-telegram: Yet another telegram ChatGPT bot.