Library / Building Blocks & Utilities
Building Blocks & Utilities
Build an event-driven pub/sub bus with webhooks, HTTP services, and Slack
When an API call/webhook arrives, it provides a reusable building block using Slack.
What it does
## Event-Driven Architecture (Advanced) A reusable, general-purpose event bus built in n8n. Any producer (webhook, cron, another workflow) publishes an *event envelope* — {eventType, eventId, source, timestamp, payload} — into a single Event Ingress entry point. From there: 1. Validation & enrichment — envelope is schema-checked and stamped with routing metadata 2. Event Store (append-only log) — every event is persisted before anything else happens, so nothing is ever routed without first being durably recorded (event sourcing pattern) 3. Router (Switch) — routes by eventType to one or more subscriber branches, fan-out style; unmatched types fall through to a catch-all 4. Subscribers — independent branches (order service, notification service, analytics service...) each with their own try/fail handling — one subscriber failing never blocks another 5. Retry with backoff — a failed subscriber delivery is retried a bounded number of times with increasing delay 6. Dead-Letter Queue — deliveries that exhaust retries are written to a DLQ table/queue and raise a Slack alert, instead of silently vanishing 7. Ack — successful delivery is recorded back on the event store row This is the classic pub/sub + event sourcing + DLQ trio, implemented with n8n-native building blocks so it runs anywhere n8n runs, with no external broker required (swap the Postgres-style HTTP nodes for Kafka/RabbitMQ/SQS via their REST APIs if you outgrow this). ### Setup 1. Import into n8n 2. Set - Event Bus Config: event store endpoint, DLQ endpoint, retry policy, Slack channel, subscriber endpoints 3. Point each 'Subscriber -' HTTP node at your real service (or replace with a Function/DB node for in-n8n logic) 4. Wire your real producers (webhooks, other workflows via Execute Workflow, schedule triggers) into 'Event Ingress - Webhook' or trigger this as a sub-workflow with 'Event Ingress - Execute Workflow Trigger' 5. Activate ### Customize - Add a subscriber: duplicate a 'Subscriber -' branch off the Switch node, add its eventType case - Change fan-out to fan-in: replace Switch with a Merge if you want every event to hit every subscriber unconditionally - Swap the event store / DLQ HTTP nodes for a native Postgres/Airtable node if you prefer
The steps
- Event Ingress - Webhook
- Event Ingress - Execute Workflow Trigger
- Merge - Ingress Sources
- Set - Event Bus Config
- Code 1 - Validate & Enrich Envelope
- IF - Envelope Valid
- Respond - Invalid Envelope
- HTTP Request - Append to Event Store
- Respond - Event Accepted
- Switch - Route by Event Type
- Code - Unknown Event Type
- Subscriber - Order Service
- Subscriber - Notification Service
- Subscriber - Analytics Service
23 steps in total.
Similar automations
Calendar & SchedulingPublish approved appointment services to Square Appointments and Wix Bookings46 stepsBuilding Blocks & UtilitiesTest an n8n Sub-Workflow with Sample Input5 stepsContent Writing & GenerationCreate Data-Driven UX Personas with Perplexity and OpenAI11 stepsReports, Analytics & DashboardsCreate Data-Driven SEO Reports from Articles with BigQuery23 steps