Skip to content

A ChatGPT bot for Telegram based on Node.js. Works with chatgpt lib ver 4+.

License

Notifications You must be signed in to change notification settings

Armas0n/chatgpt-headless-telegram-bot

 
 

Repository files navigation

ChatGPT Telegram Bot

badge:version license

A ChatGPT bot for Telegram based on Node.js.

Features

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 with command
  • Typing indicator, Markdown formatting, ...

Usage

Start the server

Note This bot uses a (https://github.com/transitive-bullshit/chatgpt-api), please make sure you have Node.js >= 18 installed.

To get started, follow these steps:

  1. Make a copy of the file .env.example and rename it as .env.
  2. In the .env file, enter your OpenAI API token and Telegram bot token.
  3. 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.
  4. You can also specify the command to invoke the bot in group chats. The default command is /chat.

Then you can start the bot with:

pnpm install
pnpm build && pnpm start

Chat with the bot in Telegram

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.

Note When using a command in a group, make sure to include a mention after the command, like /help@chatgpt_bot.

Advanced

Docker

You can also try this docker image by running the following command from the project root folder:

docker compose up

Changelog

Following changes have been made compared to the original RainEggplant version:

  • /refresh command has been deprecated
  • API updated according to changes in @transitive-bullshit/chatgpt-api version 4.0.2 (no browser login and a more lightweight solution overall)

LICENSE

MIT License.

Credits

About

A ChatGPT bot for Telegram based on Node.js. Works with chatgpt lib ver 4+.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 84.8%
  • Dockerfile 8.8%
  • Shell 6.4%