Files
nexus/wiki/concepts/Telegram-Webhook.md
2026-04-16 13:01:42 +08:00

1.4 KiB
Raw Blame History

title, type, tags
title type tags
Telegram Webhook concept
telegram
webhook
bot
integration

定义

Telegram Webhook 是一种服务端回调机制Telegram 服务器在用户发送消息后,将 HTTP POST 请求推送至用户配置的公网 HTTPS URL。

工作原理

  1. 在 Telegram BotFather 创建机器人,获得 Bot Token
  2. 向 Telegram API 设置 Webhook URLhttps://api.telegram.org/bot<TOKEN>/setWebhook?url=https://your-domain.com/webhook
  3. 用户发送消息 → Telegram → POST 到配置的 URL
  4. 服务端处理请求,可返回响应消息

核心约束

  • 必须使用 HTTPSTelegram 强制要求,不支持 HTTP 或自签名证书
  • 公网可达Telegram 服务器必须能访问该 URL
  • 响应时间限制Telegram 要求 5 秒内响应,否则视为失败

n8n 集成

与 Polling 对比

特性 Webhook Polling
实时性 立即推送 轮询间隔决定
服务器负载 高(持续请求)
需要公网
部署复杂度 高(需要 HTTPS

相关