API 轮询事件路由
第 6 部分 · 案例 5.2 · 🔄 数据管道
难度 🟡 中等 · 耗时 ~25 分钟 · 核心节点 Schedule × Split Out × Switch
老旧第三方系统没 Webhook?只能轮询。这个 workflow 演示了”5 分钟轮询 + 事件路由”的标准套路——拉一批新事件后按 type 字段分发到不同 Slack 频道。
🔍 工作流连线图
Section titled “🔍 工作流连线图” ▦ workflow api-polling-router.workflow.json Lv.2
📋 关键节点
Section titled “📋 关键节点” ⚙ key-config.txt
Every 5 min (Schedule):
Mode: Every N Minutes
Minutes: 5
Fetch Events:
GET https://api.example.com/events?since=last_poll
返回 { events: [{ type, payload }, ...] }
Split Events:
Field: events
→ 把数组拆成 N 个 items
Route by Event Type (Switch):
Output 0: type = "user.created"
Output 1: type = "order.placed"
Output 2: type = "subscription.cancelled"
3 个 Slack 节点分别接 Switch 的 3 个输出口
📥 一键复制 Workflow JSON
Section titled “📥 一键复制 Workflow JSON” 📋 api-polling-router.workflow.json