import { Novu } from '@novu/node';
const novu = new Novu("<NOVU_API_KEY>");
await novu.trigger('<WORKFLOW_TRIGGER_IDENTIFIER>',
{
to: {
subscriberId: '<UNIQUE_SUBSCRIBER_IDENTIFIER>',
email: 'john@doemail.com',
firstName: 'John',
lastName: 'Doe',
},
payload: {
name: "Hello World",
organization: {
logo: 'https://happycorp.com/logo.png',
},
},
}
);
use Novu\SDK\Novu;
$novu = new Novu(<NOVU_API_KEY>);
$novu->triggerEvent([
'name' => '<WORKFLOW_TRIGGER_IDENTIFIER>',
'payload' => ['customVariables' => 'Hello'],
'to' => [
'subscriberId' => '<UNIQUE_SUBSCRIBER_IDENTIFIER>',
'phone' => '07983882186'
]
])->toArray();
curl -X POST https://api.novu.co/v1/events/trigger \
-H "Authorization: ApiKey <NOVU_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "<WORKFLOW_TRIGGER_IDENTIFIER>",
"to": {
"subscriberId": "<UNIQUE_SUBSCRIBER_IDENTIFIER>",
"email": "john@doemail.com",
"firstName": "John",
"lastName": "Doe"
},
"payload": {
"name": "Hello World",
"organization": {
"logo": "https://happycorp.com/logo.png"
}
}
}'
require 'novu'
client = Novu::Client.new('<NOVU_API_KEY>')
payload = {
'name' => '<WORKFLOW_TRIGGER_IDENTIFIER>',
'payload' => { # optional
'first-name' => 'Adam' # optional
},
'to' => {
'subscriberId' => '<UNIQUE_SUBSCRIBER_IDENTIFIER>'
},
'transactionId' => '89kjfke9893' #optional
}
client.trigger_event(payload)
package main
import (
"context"
"fmt"
novu "github.com/novuhq/go-novu/lib"
"log"
)
func main() {
subscriberID := "<UNIQUE_SUBSCRIBER_IDENTIFIER>"
apiKey := "<NOVU_API_KEY>"
eventId := "<WORKFLOW_TRIGGER_IDENTIFIER>"
ctx := context.Background()
to := map[string]interface{}{
"lastName": "Doe",
"firstName": "John",
"subscriberId": subscriberID,
"email": "john@doemail.com",
}
payload := map[string]interface{}{
"name": "Hello World",
"organization": map[string]interface{}{
"logo": "https://happycorp.com/logo.png",
},
}
data := novu.ITriggerPayloadOptions{To: to, Payload: payload}
novuClient := novu.NewAPIClient(apiKey, &novu.Config{})
resp, err := novuClient.EventApi.Trigger(ctx, eventId, data)
if err != nil {
log.Fatal("novu error", err.Error())
return
}
}
from novu.api import EventApi
url = "https://api.novu.co"
api_key = "<NOVU_API_KEY>"
novu = EventApi(url, api_key).trigger(
name="<WORKFLOW_TRIGGER_IDENTIFIER>", # This is the Workflow ID. It can be found on the workflow page.
recipients="<UNIQUE_SUBSCRIBER_IDENTIFIER>", # The subscriber ID can be gotten from the dashboard.
payload={}, # Your custom Novu payload goes here
)
import co.novu.common.base.Novu;
import co.novu.api.common.SubscriberRequest;
import co.novu.api.events.requests.TriggerEventRequest;
import co.novu.api.events.responses.TriggerEventResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "<NOVU_API_KEY>";
Novu novu = new Novu(apiKey);
SubscriberRequest subscriberRequest = new SubscriberRequest();
subscriberRequest.setEmail("<EMAIL_ADDRESS>");
subscriberRequest.setFirstName("<FIRST_NAME>");
subscriberRequest.setLastName("<LAST_NAME>");
subscriberRequest.setPhone("<PHONE_NUMBER>");
subscriberRequest.setAvatar("<AVATAR>");
subscriberRequest.setSubscriberId("<SUBSCRIBER_ID>");
TriggerEventRequest triggerEventRequest = new TriggerEventRequest();
triggerEventRequest.setName("<NAME>");
triggerEventRequest.setTo(subscriberRequest);
triggerEventRequest.setPayload(Collections.singletonMap("<CUSTOM_VARIABLE_NAME>", "<CUSTOM_VARIABLE_VALUE>"));
TriggerEventResponse response = novu.triggerEvent(triggerEventRequest);
}
}
using Novu.DTO;
using Novu.Models;
using Novu;
var novuConfiguration = new NovuClientConfiguration
{
/**
* Defaults to https://api.novu.co/v1
*/
Url = "https://novu-api.my-domain.com/v1",
ApiKey = "12345",
};
var novu = new NovuClient(novuConfiguration);
public class OnboardEventPayload
{
[JsonProperty("username")]
public string Username { get; set; }
[JsonProperty("welcomeMessage")]
public string WelcomeMessage { get; set; }
}
var onboardingMessage = new OnboardEventPayload
{
Username = "jdoe",
WelcomeMessage = "Welcome to novu-dotnet"
};
var payload = new EventTriggerDataDto()
{
EventName = "onboarding",
To = { SubscriberId = "subscriberId" },
Payload = onboardingMessage
};
var trigger = await novu.Event.Trigger(payload);
{
"data": {
"acknowledged": true,
"status": "processed",
"transactionId": "string"
}
}
Trigger event
Trigger event is the main (and only) way to send notifications to subscribers. The trigger identifier is used to match the particular workflow associated with it. Maximum number of recipients can be 100. Additional information can be passed according the body interface below. To prevent duplicate triggers, you can optionally pass a transactionId in the request body. If the same transactionId is used again, the trigger will be ignored. The retention period depends on your billing tier.
import { Novu } from '@novu/node';
const novu = new Novu("<NOVU_API_KEY>");
await novu.trigger('<WORKFLOW_TRIGGER_IDENTIFIER>',
{
to: {
subscriberId: '<UNIQUE_SUBSCRIBER_IDENTIFIER>',
email: 'john@doemail.com',
firstName: 'John',
lastName: 'Doe',
},
payload: {
name: "Hello World",
organization: {
logo: 'https://happycorp.com/logo.png',
},
},
}
);
use Novu\SDK\Novu;
$novu = new Novu(<NOVU_API_KEY>);
$novu->triggerEvent([
'name' => '<WORKFLOW_TRIGGER_IDENTIFIER>',
'payload' => ['customVariables' => 'Hello'],
'to' => [
'subscriberId' => '<UNIQUE_SUBSCRIBER_IDENTIFIER>',
'phone' => '07983882186'
]
])->toArray();
curl -X POST https://api.novu.co/v1/events/trigger \
-H "Authorization: ApiKey <NOVU_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "<WORKFLOW_TRIGGER_IDENTIFIER>",
"to": {
"subscriberId": "<UNIQUE_SUBSCRIBER_IDENTIFIER>",
"email": "john@doemail.com",
"firstName": "John",
"lastName": "Doe"
},
"payload": {
"name": "Hello World",
"organization": {
"logo": "https://happycorp.com/logo.png"
}
}
}'
require 'novu'
client = Novu::Client.new('<NOVU_API_KEY>')
payload = {
'name' => '<WORKFLOW_TRIGGER_IDENTIFIER>',
'payload' => { # optional
'first-name' => 'Adam' # optional
},
'to' => {
'subscriberId' => '<UNIQUE_SUBSCRIBER_IDENTIFIER>'
},
'transactionId' => '89kjfke9893' #optional
}
client.trigger_event(payload)
package main
import (
"context"
"fmt"
novu "github.com/novuhq/go-novu/lib"
"log"
)
func main() {
subscriberID := "<UNIQUE_SUBSCRIBER_IDENTIFIER>"
apiKey := "<NOVU_API_KEY>"
eventId := "<WORKFLOW_TRIGGER_IDENTIFIER>"
ctx := context.Background()
to := map[string]interface{}{
"lastName": "Doe",
"firstName": "John",
"subscriberId": subscriberID,
"email": "john@doemail.com",
}
payload := map[string]interface{}{
"name": "Hello World",
"organization": map[string]interface{}{
"logo": "https://happycorp.com/logo.png",
},
}
data := novu.ITriggerPayloadOptions{To: to, Payload: payload}
novuClient := novu.NewAPIClient(apiKey, &novu.Config{})
resp, err := novuClient.EventApi.Trigger(ctx, eventId, data)
if err != nil {
log.Fatal("novu error", err.Error())
return
}
}
from novu.api import EventApi
url = "https://api.novu.co"
api_key = "<NOVU_API_KEY>"
novu = EventApi(url, api_key).trigger(
name="<WORKFLOW_TRIGGER_IDENTIFIER>", # This is the Workflow ID. It can be found on the workflow page.
recipients="<UNIQUE_SUBSCRIBER_IDENTIFIER>", # The subscriber ID can be gotten from the dashboard.
payload={}, # Your custom Novu payload goes here
)
import co.novu.common.base.Novu;
import co.novu.api.common.SubscriberRequest;
import co.novu.api.events.requests.TriggerEventRequest;
import co.novu.api.events.responses.TriggerEventResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "<NOVU_API_KEY>";
Novu novu = new Novu(apiKey);
SubscriberRequest subscriberRequest = new SubscriberRequest();
subscriberRequest.setEmail("<EMAIL_ADDRESS>");
subscriberRequest.setFirstName("<FIRST_NAME>");
subscriberRequest.setLastName("<LAST_NAME>");
subscriberRequest.setPhone("<PHONE_NUMBER>");
subscriberRequest.setAvatar("<AVATAR>");
subscriberRequest.setSubscriberId("<SUBSCRIBER_ID>");
TriggerEventRequest triggerEventRequest = new TriggerEventRequest();
triggerEventRequest.setName("<NAME>");
triggerEventRequest.setTo(subscriberRequest);
triggerEventRequest.setPayload(Collections.singletonMap("<CUSTOM_VARIABLE_NAME>", "<CUSTOM_VARIABLE_VALUE>"));
TriggerEventResponse response = novu.triggerEvent(triggerEventRequest);
}
}
using Novu.DTO;
using Novu.Models;
using Novu;
var novuConfiguration = new NovuClientConfiguration
{
/**
* Defaults to https://api.novu.co/v1
*/
Url = "https://novu-api.my-domain.com/v1",
ApiKey = "12345",
};
var novu = new NovuClient(novuConfiguration);
public class OnboardEventPayload
{
[JsonProperty("username")]
public string Username { get; set; }
[JsonProperty("welcomeMessage")]
public string WelcomeMessage { get; set; }
}
var onboardingMessage = new OnboardEventPayload
{
Username = "jdoe",
WelcomeMessage = "Welcome to novu-dotnet"
};
var payload = new EventTriggerDataDto()
{
EventName = "onboarding",
To = { SubscriberId = "subscriberId" },
Payload = onboardingMessage
};
var trigger = await novu.Event.Trigger(payload);
{
"data": {
"acknowledged": true,
"status": "processed",
"transactionId": "string"
}
}
Authorization field like the example shown below:E.g ApiKey 18d2e625f05d80eimport { Novu } from '@novu/node';
const novu = new Novu("<NOVU_API_KEY>");
await novu.trigger('<WORKFLOW_TRIGGER_IDENTIFIER>',
{
to: {
subscriberId: '<UNIQUE_SUBSCRIBER_IDENTIFIER>',
email: 'john@doemail.com',
firstName: 'John',
lastName: 'Doe',
},
payload: {
name: "Hello World",
organization: {
logo: 'https://happycorp.com/logo.png',
},
},
}
);
use Novu\SDK\Novu;
$novu = new Novu(<NOVU_API_KEY>);
$novu->triggerEvent([
'name' => '<WORKFLOW_TRIGGER_IDENTIFIER>',
'payload' => ['customVariables' => 'Hello'],
'to' => [
'subscriberId' => '<UNIQUE_SUBSCRIBER_IDENTIFIER>',
'phone' => '07983882186'
]
])->toArray();
curl -X POST https://api.novu.co/v1/events/trigger \
-H "Authorization: ApiKey <NOVU_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "<WORKFLOW_TRIGGER_IDENTIFIER>",
"to": {
"subscriberId": "<UNIQUE_SUBSCRIBER_IDENTIFIER>",
"email": "john@doemail.com",
"firstName": "John",
"lastName": "Doe"
},
"payload": {
"name": "Hello World",
"organization": {
"logo": "https://happycorp.com/logo.png"
}
}
}'
require 'novu'
client = Novu::Client.new('<NOVU_API_KEY>')
payload = {
'name' => '<WORKFLOW_TRIGGER_IDENTIFIER>',
'payload' => { # optional
'first-name' => 'Adam' # optional
},
'to' => {
'subscriberId' => '<UNIQUE_SUBSCRIBER_IDENTIFIER>'
},
'transactionId' => '89kjfke9893' #optional
}
client.trigger_event(payload)
package main
import (
"context"
"fmt"
novu "github.com/novuhq/go-novu/lib"
"log"
)
func main() {
subscriberID := "<UNIQUE_SUBSCRIBER_IDENTIFIER>"
apiKey := "<NOVU_API_KEY>"
eventId := "<WORKFLOW_TRIGGER_IDENTIFIER>"
ctx := context.Background()
to := map[string]interface{}{
"lastName": "Doe",
"firstName": "John",
"subscriberId": subscriberID,
"email": "john@doemail.com",
}
payload := map[string]interface{}{
"name": "Hello World",
"organization": map[string]interface{}{
"logo": "https://happycorp.com/logo.png",
},
}
data := novu.ITriggerPayloadOptions{To: to, Payload: payload}
novuClient := novu.NewAPIClient(apiKey, &novu.Config{})
resp, err := novuClient.EventApi.Trigger(ctx, eventId, data)
if err != nil {
log.Fatal("novu error", err.Error())
return
}
}
from novu.api import EventApi
url = "https://api.novu.co"
api_key = "<NOVU_API_KEY>"
novu = EventApi(url, api_key).trigger(
name="<WORKFLOW_TRIGGER_IDENTIFIER>", # This is the Workflow ID. It can be found on the workflow page.
recipients="<UNIQUE_SUBSCRIBER_IDENTIFIER>", # The subscriber ID can be gotten from the dashboard.
payload={}, # Your custom Novu payload goes here
)
import co.novu.common.base.Novu;
import co.novu.api.common.SubscriberRequest;
import co.novu.api.events.requests.TriggerEventRequest;
import co.novu.api.events.responses.TriggerEventResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "<NOVU_API_KEY>";
Novu novu = new Novu(apiKey);
SubscriberRequest subscriberRequest = new SubscriberRequest();
subscriberRequest.setEmail("<EMAIL_ADDRESS>");
subscriberRequest.setFirstName("<FIRST_NAME>");
subscriberRequest.setLastName("<LAST_NAME>");
subscriberRequest.setPhone("<PHONE_NUMBER>");
subscriberRequest.setAvatar("<AVATAR>");
subscriberRequest.setSubscriberId("<SUBSCRIBER_ID>");
TriggerEventRequest triggerEventRequest = new TriggerEventRequest();
triggerEventRequest.setName("<NAME>");
triggerEventRequest.setTo(subscriberRequest);
triggerEventRequest.setPayload(Collections.singletonMap("<CUSTOM_VARIABLE_NAME>", "<CUSTOM_VARIABLE_VALUE>"));
TriggerEventResponse response = novu.triggerEvent(triggerEventRequest);
}
}
using Novu.DTO;
using Novu.Models;
using Novu;
var novuConfiguration = new NovuClientConfiguration
{
/**
* Defaults to https://api.novu.co/v1
*/
Url = "https://novu-api.my-domain.com/v1",
ApiKey = "12345",
};
var novu = new NovuClient(novuConfiguration);
public class OnboardEventPayload
{
[JsonProperty("username")]
public string Username { get; set; }
[JsonProperty("welcomeMessage")]
public string WelcomeMessage { get; set; }
}
var onboardingMessage = new OnboardEventPayload
{
Username = "jdoe",
WelcomeMessage = "Welcome to novu-dotnet"
};
var payload = new EventTriggerDataDto()
{
EventName = "onboarding",
To = { SubscriberId = "subscriberId" },
Payload = onboardingMessage
};
var trigger = await novu.Event.Trigger(payload);
{
"data": {
"acknowledged": true,
"status": "processed",
"transactionId": "string"
}
}
Idempotent nature of transactionId
Idempotent nature of transactionId
transactionId within Novu is a unique identifier that is used to ensure the idempotent nature of notification delivery.When you trigger an event to send a notification, you have the option to provide a transactionId. If you do not provide one, Novu will generate a UUID for you.This identifier is particularly useful for preventing the same notification from being sent multiple times in case the trigger event is inadvertently called more than once.By leveraging the transactionId, you can make idempotent requests, which means if the same transactionId is used in another request, Novu’s API will recognize it and will not send the same notification again.transactionId.Authorizations
API key authentication. Allowed headers-- "Authorization: ApiKey <api_key>".
Body
The trigger identifier of the workflow you wish to send. This identifier can be found on the workflow page.
"workflow_identifier"
The recipients list of people who will receive the notification.
Show child attributes
Show child attributes
The payload object is used to pass additional custom information that could be used to render the workflow, or perform routing rules based on it. This data will also be available when fetching the notifications feed from the API to display certain parts of the UI.
{ "comment_id": "string", "post": { "text": "string" } }
This could be used to override provider specific configurations
{ "fcm": { "data": { "key": "value" } } }
A unique identifier for this transaction, we will generated a UUID if not provided.
It is used to display the Avatar of the provided actor's subscriber id or actor object. If a new actor object is provided, we will create a new subscriber in our system
It is used to specify a tenant context during trigger event. Existing tenants will be updated with the provided details.
Response
Created
If trigger was acknowledged or not
Status for trigger
error, trigger_not_active, no_workflow_active_steps_defined, no_workflow_steps_defined, processed, subscriber_id_missing, no_tenant_found In case of an error, this field will contain the error message
Transaction id for trigger
Was this page helpful?