Enbbox Docs

Triggers

Triggering notifications in Enbbox. API calls, workflow execution, payload data, subscriber targeting, and bulk trigger operations.

A Trigger is an API call that starts a workflow execution. This is how your application tells Enbbox to send notifications.

Basic Trigger

await enbbox.trigger("workflow-identifier", {
  to: { subscriberId: "user-123" },
  payload: {
    key: "value",
  },
});

Trigger Components

ComponentDescription
workflowIdThe identifier of the workflow to execute
toThe subscriber(s) or topic(s) to notify
payloadDynamic data for template rendering
overridesOverride default channel settings (optional)
actorThe user who initiated the action (optional)
transactionIdIdempotency key to prevent duplicate notifications (optional)

Trigger Targets

Single Subscriber

await enbbox.trigger("order-shipped", {
  to: { subscriberId: "user-123" },
  payload: { orderNumber: "ORD-456" },
});

Multiple Subscribers

await enbbox.trigger("system-maintenance", {
  to: [
    { subscriberId: "user-1" },
    { subscriberId: "user-2" },
    { subscriberId: "user-3" },
  ],
  payload: { maintenanceWindow: "2024-03-15 02:00 UTC" },
});

Topic

await enbbox.trigger("product-update", {
  to: [{ type: "Topic", topicKey: "beta-testers" }],
  payload: { feature: "Dark Mode" },
});

Payload Data

The payload object contains dynamic data used to populate notification templates:

await enbbox.trigger("order-confirmation", {
  to: { subscriberId: "user-123" },
  payload: {
    orderNumber: "ORD-789",
    items: ["Widget A", "Widget B"],
    total: "$49.99",
    deliveryDate: "March 20, 2024",
  },
});

In templates, access payload data with Handlebars syntax: {{orderNumber}}, {{total}}

Actor

Specify the user who performed the action that triggered the notification:

await enbbox.trigger("comment-added", {
  to: { subscriberId: "post-author-123" },
  actor: { subscriberId: "commenter-456" },
  payload: { comment: "Great post!" },
});

The actor's avatar and name can be displayed in in-app notifications.

Transaction ID

Use transactionId for idempotency — preventing duplicate notifications if the same trigger is sent multiple times:

await enbbox.trigger("payment-received", {
  to: { subscriberId: "user-123" },
  transactionId: `payment-${paymentId}`,
  payload: { amount: "$100" },
});

Cancel a Triggered Event

Cancel a pending workflow execution using the transaction ID:

await enbbox.events.cancel(transactionId);

This is useful for cancelling delayed notifications when the user has already taken the expected action.

On this page