ChatGPT Telegram Bot
The ChatGPT Telegram Bot is an innovative integration of the advanced ChatGPT language model into Telegram, designed to facilitate seamless interactions between users and AI. Developed using Node.js, this bot supports both browserless and browser-based APIs, offering versatility in its applications.
Recent Updates
The project has been actively maintained, with the notable recent release being version 2.5.0 on April 3, 2023. Key enhancements include:
- Per-Chat Conversations: Users can now engage in individual conversations.
- Optional Message Queue: Allows users to select message queuing as an optional feature.
Previous updates have introduced significant features like support for timeout mechanisms, Docker image availability, integration with the official OpenAI chat completions API, and more. These updates ensure the bot remains robust and responsive to user needs.
Features
ChatGPT Telegram Bot offers a comprehensive set of features:
- Compatibility with both browserless (official and unofficial) and browser-based APIs.
- Functionality for both private and group chats.
- Operates efficiently in privacy mode, allowing the bot to view only select messages.
- Enhanced security with bot access control based on user and group IDs.
- Ability to reset chat threads and refresh sessions using commands.
- Manages message queues to prevent rate limits.
- Provides visual feedback with a typing indicator and supports Markdown formatting.
- Bypasses Cloudflare protection, automating CAPTCHA tasks.
- Customization options for defining bot identity and behavior.
- Offers user-friendly logging for tracking interactions.
Usage
Three Types of APIs
The bot supports three API types, each with specific attributes:
- Official API: Uses the gpt-3.5-turbo model via OpenAI's official API. This method is robust but not free.
- Unofficial API: Accesses ChatGPT via a proxy server, which is free and uses real ChatGPT but might be rate-limited and dependent on third-party servers.
- Browser API: Requires browser-based operations using Puppeteer. It utilizes the real ChatGPT but tends to be less stable and more resource-intensive.
Caution: There's a risk that using unofficial or browser APIs might lead to account suspension by OpenAI.
Getting Started
Option 1: Node
-
Clone the Project: Download the codebase to your machine.
-
Configure Settings: Create a
local.json
file in theconfig/
directory to customize settings. -
Run the Bot: Install dependencies and launch the application using:
pnpm install pnpm build && pnpm start
Option 2: Docker
-
Setup Configuration: Prepare a
local.json
file in aconfig
directory. -
Launch with Docker: Execute the following to start the bot:
docker run -d -v ./config:/app/config raineggplant/chatgpt-telegram-bot:latest
Interacting with the Bot
Engage with the bot via Telegram by:
- Sending direct messages.
- Prefacing messages with a designated command (e.g.,
/chat
). - Replying to the bot’s previous message.
Common commands include:
/help
: Displays available commands and usage instructions./reset
: Clears the current conversation history./reload
: Refreshes the ChatGPT session (available for admins using the browser-based API).
Ensure that the bot's privacy settings are enabled before adding it to a group to avoid unintended interactions.
Advanced Usage
Running the bot on a headless server with a browser-based API can be achieved using Xvfb, allowing execution without a physical GUI environment.
Acknowledgments
Significant contributions have been made by various open-source projects, such as:
- ChatGPT API for its node client.
- Node.js Telegram Bot API for Telegram Bot integration.
ChatGPT Telegram Bot is released under the MIT License, inviting users to contribute and use it freely. Users are encouraged to star the repository if they find it valuable.