Webhook Transforms
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
Phases
-
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
-
Register webhook URL. Provide the external service with the webhook endpoint.
-
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
-
Error handling:
- If transform throws: log raw payload to
_dead-letter/{timestamp}.md - Surface error type to agent
- Retry once
- Don't lose events
- If transform throws: log raw payload to
Example Transforms
SMS Received
Input: {from: "+1555...", body: "Meeting …