webhook-transforms

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Webhook Transforms

Webhook 转换

Contract

契约

This skill guarantees:
  • External events are transformed into brain pages with proper citations
  • Raw payloads are preserved (dead-letter queue if transform fails)
  • Entity extraction runs on every transformed event
  • Input sanitization: no raw HTML/script passes to brain pages
  • Error handling: transform failure logs raw payload, retries once
本Skill保证:
  • 外部事件会被转换为带有正确引用的大脑页面
  • 原始负载会被保留(转换失败时存入死信队列)
  • 对每个转换后的事件执行实体提取
  • 输入清理:不会有原始HTML/脚本传入大脑页面
  • 错误处理:转换失败时记录原始负载,重试一次

Phases

阶段

  1. Define transform. Map event schema to brain page format:
    • Input: raw webhook payload (JSON)
    • Output: brain page content (markdown) + metadata (slug, type, citations)
    • Must sanitize: strip HTML tags, escape script content
  2. Register webhook URL. Provide the external service with the webhook endpoint.
  3. On event received:
    • Parse payload
    • Run transform function
    • Write brain page via
      gbrain put
    • Extract entities, run enrichment
    • Add timeline entries to mentioned entities
    • Sync:
      gbrain sync
  4. Error handling:
    • If transform throws: log raw payload to
      _dead-letter/{timestamp}.md
    • Surface error type to agent
    • Retry once
    • Don't lose events
  1. 定义转换规则。将事件 schema 映射为大脑页面格式:
    • 输入:原始Webhook负载(JSON)
    • 输出:大脑页面内容(markdown)+ 元数据(slug、类型、引用)
    • 必须执行清理:剥离HTML标签、转义脚本内容
  2. 注册Webhook URL。向外部服务提供Webhook端点。
  3. 接收事件时
    • 解析负载
    • 运行转换函数
    • 通过
      gbrain put
      写入大脑页面
    • 提取实体、执行 enrichment
    • 为提及的实体添加时间线条目
    • 同步:
      gbrain sync
  4. 错误处理
    • 若转换抛出异常:将原始负载记录至
      _dead-letter/{timestamp}.md
    • 向Agent上报错误类型
    • 重试一次
    • 不丢失任何事件

Example Transforms

转换示例

SMS Received

收到短信

Input: {from: "+1555...", body: "Meeting moved to 3pm", timestamp: "..."}
Output: Timeline entry on sender's brain page + task update if action item detected
Input: {from: "+1555...", body: "Meeting moved to 3pm", timestamp: "..."}
Output: 在发送者的大脑页面添加时间线条目 + 若检测到行动项则更新任务

Meeting Completed

会议结束

Input: {title: "Weekly sync", attendees: [...], transcript: "...", summary: "..."}
Output: Delegate to meeting-ingestion skill
Input: {title: "Weekly sync", attendees: [...], transcript: "...", summary: "..."}
Output: 委托给会议摄入Skill处理

Social Mention

社交平台提及

Input: {platform: "twitter", author: "@handle", text: "...", url: "..."}
Output: Brain page in media/ + entity extraction + backlinks
Input: {platform: "twitter", author: "@handle", text: "...", url: "..."}
Output: 在media/目录下生成大脑页面 + 实体提取 + 反向链接

Output Format

输出格式

Event transformed and written to brain. Report: "Webhook: {event_type} from {source} → {brain_page_path}"
事件转换完成并写入大脑后,报告:"Webhook: {event_type} from {source} → {brain_page_path}"

Anti-Patterns

反模式

  • Passing raw HTML/script to brain pages (XSS risk)
  • Silently dropping events when transform fails (use dead-letter queue)
  • Processing webhooks without entity extraction
  • Not sanitizing external input before brain writes
  • 将原始HTML/脚本传入大脑页面(存在XSS风险)
  • 转换失败时静默丢弃事件(应使用死信队列)
  • 处理Webhook时不执行实体提取
  • 写入大脑前未清理外部输入