Skip to content

webhooks: add rawMode config for raw JSON payload delivery#18

Merged
jhs129 merged 4 commits intomainfrom
raw-webhooks
Mar 28, 2026
Merged

webhooks: add rawMode config for raw JSON payload delivery#18
jhs129 merged 4 commits intomainfrom
raw-webhooks

Conversation

@jhs129
Copy link
Copy Markdown
Owner

@jhs129 jhs129 commented Mar 27, 2026

Hey! Here's a feature I put together to solve a real pain point with the webhook preset system — when you need the complete JSON payload rather than the formatted markdown message, the current transforms throw away data you might need for automation.

Summary

  • Adds hooks.webhooks.rawMode — an optional array of preset names that bypass the transform and deliver the full JSON payload as a formatted string
  • Session keys are auto-derived from common ID fields (entity_id, id, session_id) with an unknown fallback
  • Zero breaking changes — omitting rawMode keeps all existing behavior exactly as-is
  • Works alongside agentRoutes, so you can raw-mode a preset and route it to a specific agent

Config example

{
  hooks: {
    webhooks: {
      presets: ["readai", "ownerrez"],
      rawMode: ["ownerrez"]  // OwnerRez gets full JSON; Read.ai still gets formatted message
    }
  }
}

Changes

File What changed
src/config/types.hooks.ts Added rawMode?: string[] to WebhooksConfig
src/config/zod-schema.ts Added rawMode field to Zod webhooks schema
src/gateway/hooks.ts Pass rawMode through resolveWebhooksConfig
src/gateway/webhooks-http.ts Check rawMode before transforming; helpers for session key extraction and capitalization
src/gateway/webhooks-http.test.ts 4 new test cases (raw dispatch, id fallback, unknown fallback, mixed mode)
docs/automation/webhooks-external.md New "Raw JSON Mode" section with config example and field docs

Test plan

  • pnpm build passes
  • pnpm check — 0 warnings, 0 errors
  • All 54 webhook tests pass (15 HTTP handler + 39 transform tests)
  • Raw mode dispatches JSON.stringify(payload, null, 2) verbatim
  • Session key uses entity_ididsession_idunknown in order
  • Non-rawMode presets in the same config still use their formatted transforms

🤖 Generated with Claude Code

John Schneider and others added 4 commits March 27, 2026 19:00
Adds hooks.webhooks.rawMode — an optional array of preset names that
receive the full JSON payload string instead of a formatted markdown
message. Useful for automation where downstream processing needs
complete entity data not included in the transform.

- Config type and Zod schema updated with rawMode field
- resolveWebhooksConfig passes rawMode through to WebhooksConfigResolved
- Handler skips transform and JSON.stringifies payload when rawMode enabled
- Session keys extracted from entity_id / id / session_id with unknown fallback
- 4 new test cases covering raw, fallback, unknown, and mixed-mode dispatch
- Docs updated with Raw JSON Mode section and example

Version: bump to 2026.3.27-18 for PR #18

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Adds an m365-email webhook preset that handles Microsoft Graph API change
notifications for mailbox monitoring.

- New transform (m365-email.ts): extracts mailbox address and message ID
  from the resource path, formats an agent message with next steps
- Validation handshake: HTTP handler now responds to ?validationToken=...
  with plain text 200 before any transform/rawMode logic runs
- Registered in the webhook transform registry
- 7 unit tests for the transform + 1 integration test for the handshake
- Docs: new m365-email section with subscription setup, payload example,
  and renewal notes

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Prod config has hooks.webhooks.agentRoutes which maps preset names to
agent IDs. Adding the field to the type and Zod schema so gateway starts
without a config validation error.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Two changes to prevent missing-tool failures on fresh staging deploys:

1. Dockerfile: add @googleworkspace/cli to the npm install -g block so
   gws is always available in the image regardless of volume state.

2. staging-up.sh: add a data-sync step that copies from prod after deploy:
   - OAuth/API token JSON files (/data/*.json)
   - Google Workspace CLI config (/data/gws-config/)
   - gh CLI auth (/data/config/gh/hosts.yml)

These files live only on the persistent volume and are not in git, so
fresh staging volumes were missing them and agent tool checks would fail.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@jhs129 jhs129 merged commit 038f9c3 into main Mar 28, 2026
21 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant