Skip to main content

Integration hub

Domain events fan out to outbound integrations so a campaign can push activity to a webhook, an n8n flow, a Google Sheet, SMS/ZNS, or a CRM — configured, not coded.

Events

Canonical, stable event types emitted across the system:

EventEmitted by
play_completedengine (after every play commits)
prize_wonengine (per awarded prize)
prize_claimedreward claim
quest_completedquest completion
leaderboard_finalizedleaderboard finalize

All emission is best-effort — an integration can never fail the play/claim that triggered it.

The Hub

The Hub is the engine's EventSink. On each event it:

  1. publishes to the Redis pub/sub bus for cross-process fan-out (extra Core replicas, the future realtime gateway, out-of-process consumers); and
  2. looks up the active integrations in the event's scope that subscribe to that type (campaign-narrowed or scope-wide) and delivers through their providers.

Delivery failures are logged and skipped — never retried into the caller.

Providers

A pluggable registry keyed by integration type (same pattern as reward handlers / fulfillment channels):

TypeBehavior
webhookreal HTTP POST of the event JSON, optional X-Muse-Signature HMAC-SHA256
n8na webhook receiver (same POST + HMAC convention)
gsheet, sms, zns, crmlogging stubs — swap in a real impl by re-registering the type

Admin

EndpointPurpose
POST /api/v1/admin/integrationsregister an adapter (type, events, config)
GET /api/v1/admin/integrationslist
DELETE /api/v1/admin/integrations/{id}remove
POST /api/v1/admin/integrations/emitinject an event for testing → returns dispatch count

All under role-based authz. See Flows → Integration events.