Telegram GPT Worker: a multi-model AI Telegram bot deployed on Cloudflare Workers

Trae

General Introduction

GPT-Telegram-Worker is a multi-model AI Telegram robot based on Cloudflare Workers, supporting multiple APIs such as OpenAI, Claude, Azure, etc. The project is developed in TypeScript, with a modularized design for easy expansion to provide a fast and scalable service experience. The robot is equipped with intelligent dialog, image generation, image analysis and other functions, and supports multiple languages to meet diversified needs.

Telegram GPT Worker:部署在Cloudflare Workers上的多模型AI Telegram机器人

 

Function List

  • Multi-model support: Integrate multiple AI models such as OpenAI, Google Gemini, Anthropic Claude, Groq and Azure OpenAI.
  • Intelligent dialog: with contextual memory capability to ensure smooth and natural dialog.
  • Image Generation: Supports textual descriptions to generate images, using DALL-E and Cloudflare. Flux Technology.
  • Image analysis: support users to upload images and analyze them intelligently, using OpenAI or Google Gemini Model.
  • Multi-language support: Built-in i18n function supports 8 languages.
  • User rights management: control access rights through the whitelist function to enhance security.
  • High-performance deployment: Leverage the edge computing power of Cloudflare Workers for rapid response.
  • Efficient data management: Redis is used for data caching and management to ensure efficient processing.
  • Flux Cue Optimization: Optimize image-generated cues for Flux models via an external API.

 

Using Help

Installation process

  1. preliminary::
    • Cloudflare Account
    • Telegram Account and Bot Token
    • Upstash Redis database (requires Eviction to be enabled)
    • API key for at least one AI service
  2. Getting Started::
    • Cloning Project Warehouse:git clone https://github.com/snakeying/GPT-Telegram-Worker.git
    • Configure the necessary environment variables: in the .env file to set up information about Cloudflare, Telegram, and Redis.
    • Deploy to Cloudflare Workers:
      npm install -g @cloudflare/wrangler
      wrangler login
      wrangler init telegram-bot
      cp dist/index.js telegram-bot/
      wrangler publish
      
    • Set up a Telegram Webhook:
      curl -F "url=https://your-worker.your-subdomain.workers.dev" https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook
      

Instructions for use

  1. Activate the robot.::
    • utilization /start Command to start the robot.
    • utilization /language Switch language.
    • utilization /switchmodel Toggle the AI model.
    • utilization /new Start a new conversation.
    • utilization /history Get a summary of the conversation history.
    • utilization /help Get help information.
  2. Image Generation::
    • utilization /img command to generate an image (DALL-E).
    • utilization /flux command to generate an image (Cloudflare Flux).
  3. image analysis::
    • After uploading the image, the robot automatically performs an intelligent analysis and returns the results.
  4. Rights Management::
    • Ensure security by controlling user access rights through the whitelisting feature.
  5. data management::
    • Use Redis for data caching and management to ensure efficient processing.

Detailed Operation Procedure

  1. Configuring Environment Variables::
    • In the project root directory, create the .env file, add the following:
      TELEGRAM_BOT_TOKEN=<Your Telegram Bot Token>
      CLOUDFLARE_ACCOUNT_ID=<Your Cloudflare Account ID>
      REDIS_URL=<Your Redis URL>
      
    • Make sure that all variables are properly configured.
  2. Deploying to Cloudflare Workers::
    • Use the Wrangler CLI to deploy the project:
      wrangler publish
      
    • Configure environment variables in the Cloudflare Dashboard.
  3. Setting up the Telegram Webhook::
    • Setting up a Webhook using the Telegram Bot API:
      curl -F "url=https://your-worker.your-subdomain.workers.dev" https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook
      
  4. Use of robots::
    • After starting the robot, you can use various commands to interact with the robot, generate images, analyze pictures, switch languages and models, and so on.
© Copyright notes
AiPPT

Related posts

No comments

none
No comments...