Test with a real subscriber
A real subscriber already exists in the same environment, with thesubscriberId your app uses and the channel fields the workflow needs, such as email.
- Create the subscriber on the Subscribers page, or pass their profile on the trigger.
- Open the workflow and click Test workflow.
- Select that subscriber, fill the payload, and send.
- Open the Activity Feed and filter by that subscriber ID.
<Inbox /> component initialized with the same application identifier and subscriberId.
Integrate a workflow trigger in my app
Trigger Event API
Trigger a workflow from your backend by sending an event to the Novu API. An event represents an action in your system, for example, an order created or a comment added, and is mapped to a workflow using the workflow’s trigger identifier. CallPOST https://api.novu.co/v1/events/trigger with the environment secret key. Never put that key in frontend code. The REST field for the workflow identifier is name. The server SDKs call it workflowId. A workflow must be published before a Production trigger can run it. If the subscriber does not exist yet, passing to as an object creates them on that trigger.
When you trigger an event, you specify:
- The workflow to execute.
- The subscriber (or subscribers) the notification is intended for.
- The payload data used to personalize notification content.
- Node.js
- Python
- Go
- PHP
- .NET
- Java
- cURL
For full request options and response details, see the Trigger Event API reference.
Override the assigned agent
If the workflow has an agent assigned in Configure workflow, that agent is the default for every trigger. PassagentId on the trigger to change that for a single execution:
agentId is the public agent slug, not the Mongo _id. See Workflow-assigned agents.
- Node.js
- Python
- Go
- PHP
- .NET
- Java
- cURL
agentId: null.
Trigger a workflow with context
You can attach context data when triggering a workflow using the Event API. Context can be referenced from existing contexts created in the Novu dashboard by providing the context type and identifier or defined inline at trigger time. Any context passed with the event is available to all downstream steps and channel templates during workflow execution. When you pass a rich context object with adata field, Novu upserts the stored context data if the context already exists - similar to subscriber fields on the to object. Passing only a string identifier references the context without changing stored data.
Context data is passed using the context object in the trigger request.
- Node.js
- Python
- Go
- PHP
- .NET
- Java
- cURL
To learn how contexts work and how to manage them, see the Context documentation.
Trigger a workflow to a topic
Once you’ve created topics and added subscribers, you can trigger workflows to those subscribers in bulk. Triggering a workflow to a topic is Novu’s primary mechanism for broadcasting notifications to large audiences with a single API call. When you trigger a workflow using a topic key, Novu performs a fan-out: it resolves all subscribers in the topic and executes the workflow independently for each subscriber.To learn how to create and manage Topics, see the Topics API reference.
Trigger to a single topic
The most common use case is sending a notification to all subscribers within a single topic. This is suitable for announcements, incident updates, or targeted broadcasts. To trigger a workflow to a topic, set theto field with type: "Topic" and provide the corresponding topicKey.
- Node.js
- Python
- Go
- PHP
- .NET
- Java
- cURL
Trigger to multiple topics
You can broadcast a notification to multiple topics by passing an array to theto field. This is useful when your audience spans multiple groups, such as notifying both paying-customers and beta-testers.
Novu automatically de-duplicates subscribers. If a subscriber belongs to more than one of the specified topics, they will receive the notification only once.
- Node.js
- Python
- Go
- PHP
- .NET
- Java
- cURL
Exclude a subscriber from a topic trigger
When a workflow is triggered to a topic, all subscribers in that topic are included by default. You can exclude specific subscribers from receiving the notification for that trigger by using theexclude field.
This exclusion applies only to the current trigger request and does not modify the topic membership.
- Node.js
- Python
- Go
- PHP
- .NET
- Java
- cURL