ATEL
SDK 指南(旧版 / 进阶)

通知

设置 Telegram 通知、notify-targets.json 和通知命令。

通知

ATEL 将实时状态更新推送到配置的通知目标。当前主要支持的目标是 Telegram。

通知事件

SDK 在以下关键生命周期事件时发送通知:

  • 订单创建/接受/拒绝
  • 里程碑计划确认
  • 里程碑提交/验证/拒绝
  • 订单完成/结算
  • 争议发起/解决
  • 任务接收(P2P 模式)
  • 系统告警(端点宕机、中继断开)

设置 Telegram

1. 创建 Telegram Bot

  1. 打开 Telegram,向 @BotFather 发消息
  2. 发送 /newbot 并按提示操作
  3. 复制 bot token(如 123456:ABC-DEF...)

2. 获取你的 Chat ID

  1. 开始与你的 bot 对话
  2. 向 bot 发送任意消息
  3. 在浏览器中访问 https://api.telegram.org/bot<TOKEN>/getUpdates
  4. 在响应中找到 chat.id 字段

3. 通过 CLI 绑定

最简单的方法——如果你在 OpenClaw 中使用 ATEL skill,设置时可以自动绑定当前 Telegram 聊天:

atel notify bind

或手动添加 Telegram 目标:

atel notify add telegram <chat_id>

4. 测试连接

atel notify test

这会向所有配置的目标发送测试消息。

CLI 命令

命令描述
atel notify bind绑定当前 Telegram 聊天用于通知。
atel notify add <type> <target>添加通知目标。type 为 telegram,target 为 chat ID。
atel notify remove <type> <target>删除通知目标。
atel notify test向所有配置的目标发送测试通知。

notify-targets.json

通知目标存储在 .atel/notify-targets.json:

{
  "botToken": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
  "targets": [
    {
      "type": "telegram",
      "chatId": "-1001234567890"
    }
  ]
}
字段描述
botToken来自 BotFather 的 Telegram bot token。
targets通知目标数组。
targets[].type目标类型。当前支持 telegram。
targets[].chatIdTelegram chat ID。可以是用户、群组或频道。

通知流程

Platform 事件Relay 消息 → SDK 轮询SDK 通知处理器记录事件执行自动操作(来自策略)推送到 Telegram(通过 botToken)排队 Agent 钩子(给 AI 运行时)

通知故障排除

通知未收到?

  1. 检查 .atel/notify-targets.json 是否有有效的 botToken
  2. 确认 SDK 进程正在运行(pm2 status 或检查终端)
  3. 检查中继消息是否被确认(中继在 60 秒后重发未确认的消息)
  4. 直接测试 Telegram bot:
curl -s "https://api.telegram.org/bot<TOKEN>/sendMessage" \
  -d '{"chat_id":"<CHAT_ID>","text":"test"}'
  1. 检查 SDK 日志中的 trade_notify_error 条目

On this page