SignalLink — Webhook-to-Telegram Signal Router
A lightweight, open-source bridge that receives webhook alerts (e.g. from TradingView) and forwards them as clean, formatted messages to a Telegram bot. No paid services, no third-party subscriptions — just deploy and route.
When To Use This Skill
Use SignalLink when the user wants to:
- - Forward TradingView price alerts or strategy signals to Telegram
- Route any webhook event (uptime monitors, CI/CD pipelines, custom alerts) to Telegram
- Set up a self-hosted trading signal notification system
- Replace paid signal routing services with a free, open-source alternative
Setup
Step 1 — Get a Telegram Bot Token
- 1. Open Telegram and message @BotFather
- Send
/newbot and follow the prompts - Copy the bot token — it looks like INLINECODE1
Step 2 — Get Your Chat ID
- 1. Message @userinfobot on Telegram
- It will reply with your Chat ID
Step 3 — Configure Environment
CODEBLOCK0
Edit .env:
CODEBLOCK1
Step 4 — Run
With Docker (recommended):
CODEBLOCK2
With Python:
CODEBLOCK3
Server starts at INLINECODE3
Endpoints
| Method | Path | Description |
|---|
| GET | INLINECODE4 | Health check |
| GET |
/health | Detailed health status |
| POST |
/webhook | Main endpoint — auto-detects signal format |
| POST |
/webhook/raw | Raw key-value formatter for generic alerts |
Usage Instructions
When a user asks to forward trading signals or webhook alerts to Telegram:
- 1. Ask for their
TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID if not already set - Guide them to set up the
.env file using .env.example as a template - Start the server using Docker or Python
- Point their webhook source (e.g. TradingView) to INLINECODE12
- Optionally set
WEBHOOK_SECRET and instruct the user to pass it as the X-Webhook-Secret header
TradingView Integration
In TradingView, set the alert webhook URL to:
CODEBLOCK4
Set the alert message body to JSON:
CODEBLOCK5
Supported Payload Fields
| Field | Alias | Description |
|---|
| INLINECODE15 | INLINECODE16 | Signal direction: buy, sell, close, INLINECODE20 |
| INLINECODE21 |
ticker | Trading pair, e.g.
XAUUSD,
EURUSD,
BTCUSD |
|
price |
close | Entry or current price |
|
interval |
timeframe | Chart timeframe, e.g.
1H,
4H,
1D |
|
strategy |
strategy_name | Strategy name |
|
sl |
stop_loss | Stop loss level |
|
tp |
take_profit | Take profit level |
|
lot |
quantity | Lot size or quantity |
|
message |
msg | Custom note or description |
Testing
Send a test webhook with curl:
CODEBLOCK6
Example Telegram Output
CODEBLOCK7
Project Structure
CODEBLOCK8
Security Notes
- - Always set
WEBHOOK_SECRET in production to prevent unauthorized requests - The secret is validated via constant-time comparison to prevent timing attacks
- Never expose your
TELEGRAM_BOT_TOKEN publicly
SignalLink — Webhook到Telegram的信号路由器
一个轻量级、开源的桥梁,用于接收webhook警报(例如来自TradingView的警报),并将其作为清晰、格式化的消息转发到Telegram机器人。无需付费服务,无需第三方订阅——只需部署和路由。
何时使用此技能
当用户想要以下操作时,使用SignalLink:
- - 将TradingView价格警报或策略信号转发到Telegram
- 将任何webhook事件(运行时间监控、CI/CD流水线、自定义警报)路由到Telegram
- 搭建自托管的交易信号通知系统
- 用免费、开源替代方案替换付费信号路由服务
设置
步骤1 — 获取Telegram机器人令牌
- 1. 打开Telegram并给@BotFather发送消息
- 发送/newbot并按照提示操作
- 复制机器人令牌——格式类似123456789:ABCdef...
步骤2 — 获取您的聊天ID
- 1. 在Telegram上给@userinfobot发送消息
- 它会回复您的聊天ID
步骤3 — 配置环境
bash
cp .env.example .env
编辑.env文件:
env
TELEGRAMBOTTOKEN=在此处填写您的机器人令牌
TELEGRAMCHATID=在此处填写您的聊天ID
WEBHOOK_SECRET=在此处填写您的密钥 # 可选但推荐
PORT=8000
步骤4 — 运行
使用Docker(推荐):
bash
docker compose up -d
使用Python:
bash
pip install -r requirements.txt
python -m App.main
服务器启动于http://localhost:8000
端点
/health | 详细健康状态 |
| POST | /webhook | 主端点——自动检测信号格式 |
| POST | /webhook/raw | 通用警报的原始键值格式化器 |
使用说明
当用户要求将交易信号或webhook警报转发到Telegram时:
- 1. 如果尚未设置,询问他们的TELEGRAMBOTTOKEN和TELEGRAMCHATID
- 指导他们使用.env.example作为模板设置.env文件
- 使用Docker或Python启动服务器
- 将他们的webhook源(例如TradingView)指向http://<服务器IP>:8000/webhook
- 可选地设置WEBHOOK_SECRET,并指示用户将其作为X-Webhook-Secret标头传递
TradingView集成
在TradingView中,将警报webhook URL设置为:
http://您的服务器IP:8000/webhook
将警报消息正文设置为JSON:
json
{
action: buy,
symbol: XAUUSD,
price: {{close}},
interval: {{interval}},
strategy: 我的策略,
sl: 2330.00,
tp: 2370.00,
lot: 0.1,
message: 信号已确认。
}
支持的有效载荷字段
| 字段 | 别名 | 描述 |
|---|
| action | signal | 信号方向:buy、sell、close、neutral |
| symbol |
ticker | 交易对,例如XAUUSD、EURUSD、BTCUSD |
| price | close | 入场价或当前价格 |
| interval | timeframe | 图表时间框架,例如1H、4H、1D |
| strategy | strategy_name | 策略名称 |
| sl | stop_loss | 止损水平 |
| tp | take_profit | 止盈水平 |
| lot | quantity | 手数或数量 |
| message | msg | 自定义备注或描述 |
测试
使用curl发送测试webhook:
bash
curl -X POST http://localhost:8000/webhook \
-H Content-Type: application/json \
-H X-Webhook-Secret: 在此处填写您的密钥 \
-d {
action: buy,
symbol: XAUUSD,
price: 2345.50,
interval: 1H,
sl: 2330.00,
tp: 2370.00
}
Telegram输出示例
🟢 买入信号
🥇 交易对: XAUUSD
💰 价格: 2345.50
⏱️ 时间框架: 1H
🧠 策略: EMA交叉
🛑 止损: 2330.00
🎯 止盈: 2370.00
📦 手数/数量: 0.1
📝 信号已确认。
─────────────────────
⚡ 由SignalLink提供支持
项目结构
SignalLink/
├── App/
│ ├── main.py # FastAPI入口点
│ ├── webhook.py # 请求处理与认证
│ ├── formatter.py # 有效载荷 → Telegram消息
│ ├── telegram.py # Telegram Bot API客户端
│ └── config.py # 环境配置
├── Examples/
│ ├── tradingview_payload.json
│ └── custom_payload.json
├── .env.example
├── requirements.txt
├── Dockerfile
└── docker-compose.yml
安全说明
- - 在生产环境中始终设置WEBHOOKSECRET以防止未经授权的请求
- 通过恒定时间比较验证密钥以防止时序攻击
- 切勿公开暴露您的TELEGRAMBOT_TOKEN