• Product Introduction
  • Quick Start
    • Agent Development
    • Importing a Git Repository
    • Starting From a Template
    • Direct Upload
    • Start with AI
  • Framework Guide
    • Agent
    • Frontends
      • Vite
      • React
      • Vue
      • Hugo
      • Other Frameworks
    • Backends
    • Full-stack
      • Next.js
      • Nuxt
      • Astro
      • React Router
      • SvelteKit
      • TanStack Start
      • Vike
    • Custom 404 Page
  • Project Guide
    • Project Management
    • edgeone.json
    • Configuring Cache
    • Building Output Configuration
    • Domain Management
      • Overview
      • Custom Domain
      • HTTPS Configuration
        • Overview
        • Apply for Free Certificate
        • Using Managed SSL Certificate
      • Configure DNS CNAME Record
    • Error Codes
  • Build Guide
  • Deployment Guide
    • Overview
    • Create Deploys
    • Manage Deploys
    • Deploy Button
    • Using Github Actions
    • Using Gitlab CI/CD
    • Using CNB Plugin
    • Using IDE PlugIn
    • Using CodeBuddy IDE
  • Makers for Platforms
    • Platform and Multi-Tenancy
    • Vibe Coding Solution
    • Template Example
      • Vibe Coding General Template
      • Vibe Coding Platform Template
  • Observability
    • Overview
    • Metric Analysis
    • Log Analysis
  • Functions
    • Overview
    • Edge Functions
    • Cloud Functions
      • Overview
      • Node.js
      • Python
      • Go
  • Agents
    • Overview
    • Quick Start
    • Conversation Management
    • Observability
    • Sandbox Tool
      • Overview
      • Using the Agent Framework
      • Sandbox Atomic API
      • Network Search Tool
    • Agent Authentication
  • Models
    • Overview
    • Models and Vendors
      • Overview
      • Using the Zhuque Model
      • Using the Jev Model
      • Using Vendor Keys
        • OpenAI
        • Anthropic
        • Google AI Studio
        • DeepSeek
        • MiniMax
        • Hunyuan
        • Zhipu
        • MoonShot AI
    • FAQs
  • Storage
    • Overview
    • KV
    • Blob
  • Middleware
  • AI-Native Development
    • Skills
    • MCP
    • Plugin
  • Copilot
    • Overview
    • Quick Start
  • API Token
  • EdgeOne CLI
  • Makers SDK
    • Overview
    • Examples
      • Creating a Deployment
      • Deploying via the CLI
      • Project Management
    • Projects
      • Project Operations
      • Environment Variable
    • Deployment
  • Message Notification
  • Integration Guide
    • AI
      • Makers Models Integration
      • Large Models for Images Integration
    • Database
      • Supabase Integration
      • Pages KV Integration
    • Ecommerce
      • Shopify Integration
      • WooCommerce Integration
    • Payment
      • Stripe Integration
      • Integrating Paddle
    • CMS
      • WordPress Integration
      • Contentful Integration
      • Sanity Integration
      • Payload Integration
    • Authentication
      • Supabase Integration
      • Clerk Integration
    • IM
      • Overview
      • WeCom
      • Feishu
      • DingTalk
      • Telegram
      • slack
      • Discord
  • Best Practices
    • Adding an AI Chat Assistant to a Website
    • AI Dialogue Deployment: Deploy Project with One Sentence Using Skill
    • Building Agent Applications Quickly with Makers Agents
    • Building an Ecommerce Platform with Shopify
    • Building a SaaS Site Using Supabase and Stripe
    • Building a Company Brand Site Quickly
    • How to Quickly Build a Blog Site
    • Quick Launch via Login-Free Deployment in WorkBuddy
  • Migration Guides
    • Migrating from Vercel to EdgeOne Makers
    • Migrating from Cloudflare Pages to EdgeOne Makers
    • Migrating from Netlify to EdgeOne Makers
  • Troubleshooting
  • FAQs
  • Limits
  • Pricing
  • Contact Us
  • Release Notes

Telegram

This document describes how to create a Telegram Bot through BotFather, send messages to Tencent Cloud EdgeOne Makers via Webhook, and have the Agent generate replies and return them to the original chat.

Prerequisites and Scope of Application

1. You already have a Telegram account and can access the official BotFather.
2. Makers has been activated.
3. Python 3 has been installed locally to run the Webhook registration script described in this document.
4. This document covers private chat text and group targeted commands. It does not cover channel posts, payments, attachments, or Telegram Mini Apps.

Creating a Bot and Obtaining a Token

1. Open the official BotFather in Telegram and confirm that the username is `@BotFather`.
2. Send `/newbot` and enter a display name as prompted, such as `Makers Assistant`.
3. Enter a unique Bot username. As required by BotFather, the username must end with `bot`.
4. After successful creation, copy the returned Bot Token and store it securely.
5. Record the Bot username, which will be used later to open private chats or specify the recipients of group commands.

Determining Permissions and Session Scope

Telegram does not use an OAuth Scope table. This document uses the following minimal configuration:
Scenario
Required Action
Description
Private chat with user
The user first opens the Bot and clicks **Start** or sends `/start`.
Bot cannot proactively initiate a private chat with users who have never contacted it.
Group-targeted command
Add the Bot to a test group and send `/ask@<Bot username> question`.
Keep Privacy Mode enabled. Bot does not require administrator privileges.
Reply to messages
Allow the Bot to send messages in its group.
Cannot be in a muted or message-prohibited state.
If the Bot cannot join groups, use `/setjoingroups` in BotFather to check and allow it to join groups. For the receiving scope of Privacy Mode, see Bots FAQ.

Deploying the Makers Template

2. In the project environment variable settings, fill in the following variables (copy .env.example to .env).
Environment Variable
Required
Description
TELEGRAM_BOT_TOKEN
Yes
Token returned by BotFather
TELEGRAM_WEBHOOK_SECRET_TOKEN
Yes
Generated Webhook Secret
3. Save the configuration and deploy it.
4. Copy the production HTTPS domain name, and append /telegram to the end.
5. Note that the service should be deployed in a global AZ so that the telecom service can be accessed correctly.

Registering a Webhook

1. Run the following complete command in a local terminal to create and run the registration script. The script reads the Token and Webhook Secret through hidden input.
2. The Secret you enter must match the `TELEGRAM_WEBHOOK_SECRET_TOKEN` in Makers. The script will set the current Bot's message receiving address to the URL you enter and query the registration result.
3. Use the test Bot you just created.

cat > register-telegram-webhook.py <<'PY'
import getpass
import json
import re
import urllib.error
import urllib.parse
import urllib.request

bot_token = getpass.getpass('Bot Token (hidden input):').strip()
secret = getpass.getpass('Webhook Secret (must match Makers):').strip()
webhook_url = input('Full HTTPS callback URL:').strip()
if not re.fullmatch(r'[A-Za-z0-9_-]{1,256}', secret):
raise SystemExit('Webhook Secret can only contain letters, digits, underscores, and hyphens, with a length of 1 to 256 characters.')
if not webhook_url.startswith('https://') or not webhook_url.endswith('/telegram'):
raise SystemExit('Please enter the production HTTPS domain name followed by /telegram.')

def api(method, fields):
request = urllib.request.Request(
'https://api.telegram.org/bot' + bot_token + '/' + method,
data=urllib.parse.urlencode(fields).encode(),
method='POST',
)
try:
with urllib.request.urlopen(request, timeout=30) as response:
result = json.load(response)
except urllib.error.HTTPError as error:
raise SystemExit(f'Telegram HTTP {error.code}. Check the Token and network.') from None
except urllib.error.URLError:
raise SystemExit('Unable to connect to the Telegram Bot API. Check your network.') from None
if not result.get('ok'):
raise SystemExit('Telegram rejected the request. Check the URL, certificate, and parameters.')
return result['result']

api('setWebhook', {
'url': webhook_url,
'secret_token': secret,
'allowed_updates': json.dumps(['message']),
})
info = api('getWebhookInfo', {})
print('Webhook URL:', info.get('url'))
print('Pending updates:', info.get('pending_update_count', 0))
print('Last error time:', info.get('last_error_date', 'none'))
print('Registration complete. Send a message to verify.')
PY
python3 register-telegram-webhook.py

Sending a Message and Verifying It

1. Open the Bot using the link provided by BotFather, and click Start.
2. Send `Please introduce Tencent Cloud EdgeOne Makers in one sentence.`.
3. Confirm that `Thinking…` appears in the chat, and then the message is updated with the final reply.
4. Send `Please shorten the previous answer to no more than ten words.` again, and confirm the second-round reply.



ai-agent