AI Personal Learning
and practical guidance

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

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.

GPT-Telegram-Worker: multi-model AI Telegram bot-1


 

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=
      CLOUDFLARE_ACCOUNT_ID=
      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.
AI Easy Learning

The layman's guide to getting started with AI

Help you learn how to utilize AI tools at a low cost and from a zero base.AI, like office software, is an essential skill for everyone. Mastering AI will give you an edge in your job search and half the effort in your future work and studies.

View Details>
May not be reproduced without permission:Chief AI Sharing Circle " Telegram GPT Worker: a multi-model AI Telegram bot deployed on Cloudflare Workers

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish