Get Started
Build A Workflow

Workflows & Rules Engine

Design node-based notification automation flows on the visual canvas or trigger them programmatically. Every event POST to /api/v1/events evaluates active Rules first, then triggers active Workflows whose TRIGGER node eventName matches.

1

1. How Events, Rules & Workflows Connect

When your backend POSTs to /api/v1/events, HubNest does two things in sequence:

Rules vs Workflows
Use Rules for simple "if event X → send channel Y" logic. Use Workflows for complex multi-step flows with conditions, delays, and branching across multiple channels.
  • 1. Rule Engine Evaluation: All active Rules are evaluated against the event payload. If a Rule condition matches, the Rule action (channel + template) is dispatched immediately.
  • 2. Workflow Engine Evaluation: All active Workflows are checked. Those whose TRIGGER node eventName matches the incoming eventName are executed as a DAG run.
  • Both Rule and Workflow can fire on the same event simultaneously.
  • The event response includes ruleMatched, ruleNotificationStatus, and workflowsTriggeredCount fields.
2

2. Workflow Canvas Node Types

The visual canvas supports 6 node types (verified against WorkflowEngineService.java):

  • TRIGGER: Start node — specify eventName (e.g. order.placed). Workflow runs when this event matches.
  • CONDITION: Branch node — evaluates a payload field (field, operator, value). Outgoing edges must be labeled "true" and "false".
  • SEND_ACTION: Dispatch node — specify channel (EMAIL/SMS/WHATSAPP/PUSH) and templateId (UUID of your template).
  • WAIT / DELAY: Pause node — specify duration in seconds (e.g. 3600 = wait 1 hour before next node).
  • UPDATE_FIELD: Mutation node — set field = value in the execution payload for downstream nodes.
  • END: Termination node — marks the workflow run as completed.
3

3. Build a Workflow Visually (5 Step Visual Builder Console)

Follow the 5 step visual builder guide below to create, configure, and publish active workflow DAG pipelines:

📸 Visual Step Screenshots (5 UI Stages)
Stage 01: Step 1: Open Workflows Console & Click + New WorkflowFull Size
Step 1: Open Workflows Console & Click + New Workflow
Click + New Workflow button to initialize canvas
Stage 02: Step 2: Define Event Trigger Node (order.created)Full Size
Step 2: Define Event Trigger Node (order.created)
Set LISTEN TO EVENT NAME = order.created
Stage 03: Step 3: Select Notification TemplateFull Size
Step 3: Select Notification Template
Select template: Order Confirmation Receipt
Stage 04: Step 4: Configure Channel Provider GatewayFull Size
Step 4: Configure Channel Provider Gateway
Select Channel: Email / SMS / WA / Push
Stage 05: Step 5: Publish & Live Execution Chain SummaryFull Size
Step 5: Publish & Live Execution Chain Summary
Toggle Active switch & view execution chain
Visual Execution Chain
Active workflows execute automatically in the background whenever POST /api/v1/events is called with a matching eventName.
workflow/execution-chain-summary.txt
text
1[WORKFLOW ENGINE DAG EXECUTION TRACE]
2Step 1: TRIGGER :: Event "order.created"
3Step 2: 🔀 CONDITION :: Filter (amount > 0)
4Step 3: 🚀 SEND_ACTION :: Email Gateway Template "Order Confirmation Receipt"
5Step 4: ⏱️ WAIT / DELAY :: Pause Execution (300 Seconds)
6Step 5: 🚀 SEND_ACTION :: Email Gateway Template "Shipping Tracking Alert"
7Status: COMPLETED (Total Latency: 42ms)
  • Step 1 (Console Setup): Select environment (DEV/STAGING/PROD) and click + New Workflow.
  • Step 2 (Event Binding): Drag Event Trigger node and set LISTEN TO EVENT NAME to "order.created".
  • Step 3 (Template Mapping): Select message template preset (e.g. Order Confirmation Receipt, OTP Code, Welcome Email).
  • Step 4 (Channel Gateway Routing): Pick destination channel (Email Gateway, SMS Gateway, WhatsApp Gateway, Push Gateway).
  • Step 5 (Publish Pipeline): Click Publish Workflow. Toggle Active Live switch ON. Execution chain: order.created ➔ Filter ➔ EMAIL ➔ Wait (300s) ➔ EMAIL.
4

4. Set Up the Rules Engine

Rules are simpler than Workflows — for basic "if condition → send notification" logic. Go to Developer → Integrations → Rules → New Rule:

  • Name: Give the rule a descriptive name (e.g. "High Value Order Email").
  • Condition JSON: Define the payload field condition (e.g. { "field": "amount", "operator": "gt", "value": 5000 }).
  • Action JSON: Define what to dispatch (e.g. { "channel": "EMAIL", "templateId": "<template-uuid>" }).
  • Toggle "Is Active" to ON.
  • Fire events from your backend — matching events auto-dispatch the rule action.
5

5. Fire Events from Your App

From your backend application, POST events to HubNest to trigger both Rules and Workflows. Include the recipient in the to field:

workflow/fire-event.sh
bash
1# Fire an event evaluates Rules AND Workflows simultaneously
2curl -X POST "http://localhost:8085/api/v1/events" \
3 -H "Authorization: Bearer hn_live_8f3a91b2c4e567890abcdef123456789" \
4 -H "Content-Type: application/json" \
5 -d '{
6 "eventName": "order.placed",
7 "to": {
8 "subscriberId": "user_12345",
9 "email": "user@example.com",
10 "phone": "+919876543210"
11 },
12 "payload": {
13 "customerName": "Rahul Sharma",
14 "amount": 4500,
15 "orderId": "ORD-2026-001"
16 }
17 }'
18# to.email sets payload.email for email routing
19# to.phone sets payload.phone for SMS/WhatsApp routing
20# to.subscriberId sets payload.subscriberId for subscriber lookup
6

6. Test & Monitor Execution

Monitor your workflow runs from the Developer Console:

  • Test Console: In Developer → Workflows → click your workflow → Test. Paste a sample JSON event payload and click Run Test. See step-by-step execution log including which nodes fired and what was dispatched.
  • Execution Runs Table: View all past workflow runs with status (running/completed/failed), start time, and path taken through the node graph.
  • Delivery Logs: Go to Developer → Logs to see per-notification delivery status for every message dispatched by your workflows.
  • Webhook Callbacks: Configure a webhook at Developer → Webhooks to receive real-time DELIVERED/FAILED status callbacks.
Was this guide helpful?