Files
nexus/wiki/concepts/Webhook.md

1.3 KiB
Raw Blame History

title, type, tags, sources, last_updated
title type tags sources last_updated
Webhook concept
webhook
http
api
real-time
n8n-configure-telegram-trigger
2026-04-22

Definition

Webhook 是一种服务器间实时推送数据的机制,通过 HTTP POST 请求将事件通知从发送方服务器主动推送到接收方服务器。与轮询Polling不同Webhook 是被动接收,无需客户端频繁请求。

How It Works

  1. 接收方服务器向发送方注册一个公开可访问的 HTTPS URL
  2. 发送方在特定事件发生时向该 URL 发送 HTTP POST 请求
  3. 接收方处理请求并返回响应

Telegram Webhook

Telegram Bot API 支持两种消息接收模式:

  • Polling 模式Bot 主动轮询 Telegram 服务器拉取更新
  • Webhook 模式Telegram 服务器在收到消息时主动 POST 到 Bot 指定的 HTTPS URL

Telegram 要求 Webhook URL 必须是 HTTPS 协议HTTP 或 localhost 无法使用。

n8n 与 Webhook

n8n Telegram Trigger 节点依赖 Telegram Webhook 机制接收消息。配置时需确保 n8n 实例可通过 HTTPS 访问,否则 Telegram 会拒绝注册 Webhook。

  • Telegram Trigger — n8n 中使用 Webhook 接收 Telegram 消息的节点
  • WEBHOOK_URL — n8n 环境变量,指定 Webhook URL 基础地址