Cloudflare Worker · HTTP Webhook → Telegram
Cloudflare Worker that receives HTTP webhooks and forwards the body to Telegram and/or another webhook.
| Path / Method | Behavior |
|---|---|
| GET / | Status page (“running”). Center orb → GitHub; elsewhere → copy webhook URL (location.origin). Also registers Telegram /webhook command + bot webhook in the background. |
| POST / | Business receive: forward request body to Telegram and/or a downstream https/http webhook, according to which forwarding variables are configured. Body is not modified, except optional timestamp. Optional WHITE_IPs apply here only. |
| POST /telegram | Telegram Bot callback (no IP allowlist). Admin (first chat id) can send /webhook to receive the public webhook URL. |
Typical business flow:
- Client
POSTs to your Worker root URL. - Optional IP allowlist.
- Optional timezone timestamp (
TIME_MARKER). - Message is sent to Telegram when
FORWARD_PATH_TGBOTis configured and to the downstream webhook whenFORWARD_PATH_WEBHOOKis configured. If both are configured, both receive the message. - Returns
Success(or partial/error info).
Settings → Variables and Secrets
Variable names are case-insensitive. Token, chat id, URL, timezone, and IP keep original case.
| Variable | Required | Description |
|---|---|---|
FORWARD_PATH_TGBOT |
No | Configures Telegram forwarding. Value: token,admin_id[,id2,id3...]. First id = admin (can use /webhook). All ids receive Telegram messages. |
FORWARD_PATH_WEBHOOK |
No | Configures downstream webhook forwarding. https:// and http:// are both accepted. Worker POSTs the same body. |
WHITE_IPs |
No | Comma-separated IPs for POST / only. Empty / unset = allow all. Uses CF-Connecting-IP. |
TIME_MARKER |
No | IANA timezone, e.g. Asia/Shanghai. Empty / invalid / unset = off. Appends: |
—————————
时间: 2026-08-03 02:00
Example FORWARD_PATH_TGBOT:
123456:AAF-xxxx,111111111,222222222
- Open
https://YOUR_WORKER_HOST/setuponce — it registers/webhookand reports webhook status as JSON. - Talk to the bot as the admin (first chat id) and send
/webhook. - One Telegram bot can only have one webhook URL. Use a dedicated bot for this Worker.
- Connect this repo to Workers Builds (or deploy locally).
- Build:
bun run build - Deploy:
npx wrangler deploy - Set variables in the dashboard.
- Business webhook URL:
https://YOUR_WORKER_HOST
bun install && bun run build && bun run deploycurl -X POST "https://YOUR_WORKER_URL" \
-H "Content-Type: text/plain" \
-d "hello from cfwebhook"- This project is for personal / internal notification forwarding only. You are solely responsible for how you deploy and use it.
- Do not use it for spam, phishing, abuse, or any activity that violates Cloudflare Terms, Cloudflare AUP, or Telegram Terms.
- Keep your Bot token and chat IDs secret. Prefer
WHITE_IPsin production. Anyone who canPOSTyour Worker URL can push messages into your Telegram chats. - Cloudflare / Telegram may rate-limit or suspend accounts for abuse or quota excess. The authors provide this software as-is, with no warranty, and are not liable for account bans, data loss, or damages arising from use.
MIT © 2026 jack (shengshk)
将 HTTP Webhook 请求体转发到 Telegram 和/或其他 webhook 的 Cloudflare Worker。
| 路径 / 方法 | 行为 |
|---|---|
| GET / | 状态页。点中心 → GitHub;点其他区域 → 复制 Webhook(location.origin)。后台注册 Bot 的 /webhook 命令与 Telegram Webhook。 |
| POST / | 业务接收:根据是否配置 FORWARD_PATH_TGBOT、FORWARD_PATH_WEBHOOK,转发到 Telegram 和/或下游 https/http webhook。不改动正文,仅可选追加时间戳。WHITE_IPs 只作用于此路径。 |
| POST /telegram | Telegram 回调(不走 IP 白名单)。仅管理 id(第一个) 可发 /webhook,Bot 回传公开 Webhook 链接。 |
业务流程:
- 客户端
POST到 Worker 根路径。 - 可选 IP 白名单。
- 可选时区时间戳(
TIME_MARKER)。 - 配置了
FORWARD_PATH_TGBOT就发送到 Telegram,配置了FORWARD_PATH_WEBHOOK就发送到下游 Webhook;两者都配置时同时发送。 - 返回
Success(或部分成功 / 错误信息)。
设置 → 变量和密钥
变量名大小写不敏感。Token、chat id、URL、时区、IP 保持原样。
| 变量 | 必需 | 说明 |
|---|---|---|
FORWARD_PATH_TGBOT |
否 | 配置 Telegram 转发。值为 token,管理id[,id2,id3...]。第一个 id = 管理(可 /webhook)。全部 id 收 Telegram。 |
FORWARD_PATH_WEBHOOK |
否 | 配置下游 Webhook 转发。https:// 与 http:// 均可。Worker 再 POST 同一正文。 |
WHITE_IPs |
否 | 仅限制 POST /。逗号分隔。空 / 未配置 = 不限制。 |
TIME_MARKER |
否 | IANA 时区,如 Asia/Shanghai。未配置 / 无效 = 关闭。开启时追加: |
—————————
时间: 2026-08-03 02:00
FORWARD_PATH_TGBOT 示例:
123456:AAF-xxxx,111111111,222222222
- 浏览器打开一次
https://你的Worker域名/setup,会注册/webhook,并以 JSON 返回状态。 - 用管理 id(第一个) 在 Telegram 发送
/webhook。 - 一个 Bot 只能绑定 一个 Webhook。请为本 Worker 使用独立 Bot。
- 接入 Workers Builds,或本地部署。
- 构建:
bun run build - 部署:
npx wrangler deploy - 在控制台配置变量。
- 业务 Webhook:
https://你的Worker域名
bun install && bun run build && bun run deploycurl -X POST "https://你的Worker地址" \
-H "Content-Type: text/plain" \
-d "来自 cfwebhook 的测试"- 本项目仅供个人 / 内部通知转发。部署与使用后果由使用者自行承担。
- 禁止用于垃圾信息、钓鱼、滥用,或任何违反 Cloudflare 服务条款、可接受使用政策、Telegram 服务条款 的行为。
- 请妥善保管 Bot Token 与 chat id。生产环境建议配置
WHITE_IPs。任何人只要能POST你的 Worker 地址,即可向你的 Telegram 会话推送消息。 - Cloudflare / Telegram 可能因滥用或超额限流、封禁账号。本软件按 MIT「按现状」 提供,不作任何保证;作者对账号封禁、数据丢失或由此产生的损失 不承担责任。
MIT © 2026 jack (shengshk)
