import { Novu } from "@novu/api";
import { MarkMessageActionAsSeenDtoStatus } from "@novu/api/models/components";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.subscribers.messages.updateAsSeen({
messageId: "<value>",
type: "<value>",
subscriberId: "<value>",
markMessageActionAsSeenDto: {
status: MarkMessageActionAsSeenDtoStatus.Done,
},
});
// Handle the result
console.log(result)
}
run();{
"_templateId": "<string>",
"_environmentId": "<string>",
"_messageTemplateId": "<string>",
"_organizationId": "<string>",
"_notificationId": "<string>",
"_subscriberId": "<string>",
"createdAt": "<string>",
"content": {
"type": "text",
"content": "<string>",
"url": "<string>",
"styles": {
"textAlign": "left"
}
},
"transactionId": "<string>",
"channel": "in_app",
"read": true,
"seen": true,
"cta": {
"data": {
"url": "<string>"
},
"type": "redirect",
"action": {
"status": "pending",
"buttons": [
{
"type": "primary",
"content": "<string>",
"resultContent": "<string>"
}
],
"result": {
"payload": {},
"type": "primary"
}
}
},
"status": "sent",
"errorId": "<string>",
"errorText": "<string>",
"payload": {},
"overrides": {},
"_id": "<string>",
"subscriber": {
"subscriberId": "<string>",
"_organizationId": "<string>",
"_environmentId": "<string>",
"deleted": true,
"createdAt": "<string>",
"updatedAt": "<string>",
"_id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"email": "<string>",
"phone": "<string>",
"avatar": "<string>",
"locale": "<string>",
"channels": [
{
"providerId": "slack",
"credentials": {
"webhookUrl": "<string>",
"channel": "<string>",
"deviceTokens": [
"<string>"
],
"alertUid": "<string>",
"title": "<string>",
"imageUrl": "<string>",
"state": "<string>",
"externalUrl": "<string>"
},
"_integrationId": "<string>",
"integrationIdentifier": "<string>"
}
],
"isOnline": true,
"lastOnlineAt": "<string>",
"__v": 123
},
"template": {
"name": "<string>",
"description": "<string>",
"active": true,
"draft": true,
"preferenceSettings": {
"email": true,
"sms": true,
"in_app": true,
"chat": true,
"push": true
},
"critical": true,
"tags": [
"<string>"
],
"steps": [
{
"_id": "<string>",
"uuid": "<string>",
"name": "<string>",
"_templateId": "<string>",
"active": true,
"shouldStopOnFail": true,
"template": {},
"filters": [
{
"isNegated": true,
"type": "BOOLEAN",
"value": "AND",
"children": [
{
"field": "<string>",
"value": "<string>",
"operator": "LARGER",
"on": "subscriber"
}
]
}
],
"_parentId": {},
"metadata": {
"type": "regular",
"amount": 123,
"unit": "seconds",
"digestKey": "<string>",
"backoff": true,
"backoffAmount": 123,
"backoffUnit": "seconds",
"updateMode": true
},
"replyCallback": {},
"variants": {
"_id": "<string>",
"uuid": "<string>",
"name": "<string>",
"_templateId": "<string>",
"active": true,
"shouldStopOnFail": true,
"template": {},
"filters": [
{
"isNegated": true,
"type": "BOOLEAN",
"value": "AND",
"children": [
{
"field": "<string>",
"value": "<string>",
"operator": "LARGER",
"on": "subscriber"
}
]
}
],
"_parentId": {},
"metadata": {
"type": "regular",
"amount": 123,
"unit": "seconds",
"digestKey": "<string>",
"backoff": true,
"backoffAmount": 123,
"backoffUnit": "seconds",
"updateMode": true
},
"replyCallback": {}
}
}
],
"_organizationId": "<string>",
"_creatorId": "<string>",
"_environmentId": "<string>",
"triggers": [
{
"type": "event",
"identifier": "<string>",
"variables": [
{
"name": "<string>"
}
],
"subscriberVariables": [
{
"name": "<string>"
}
]
}
],
"_notificationGroupId": "<string>",
"deleted": true,
"deletedAt": "<string>",
"deletedBy": "<string>",
"_id": "<string>",
"_parentId": "<string>",
"notificationGroup": {
"name": "<string>",
"_environmentId": "<string>",
"_organizationId": "<string>",
"_id": "<string>",
"_parentId": "<string>"
},
"data": {},
"workflowIntegrationStatus": {}
},
"templateIdentifier": "<string>",
"lastSeenDate": "<string>",
"lastReadDate": "<string>",
"subject": "<string>",
"email": "<string>",
"phone": "<string>",
"directWebhookUrl": "<string>",
"providerId": "<string>",
"deviceTokens": [
"<string>"
],
"title": "<string>",
"_feedId": "<string>"
}Update in-app (inbox) notification’s action status by its unique key identifier messageId and type field type. type field can be primary or secondary
import { Novu } from "@novu/api";
import { MarkMessageActionAsSeenDtoStatus } from "@novu/api/models/components";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.subscribers.messages.updateAsSeen({
messageId: "<value>",
type: "<value>",
subscriberId: "<value>",
markMessageActionAsSeenDto: {
status: MarkMessageActionAsSeenDtoStatus.Done,
},
});
// Handle the result
console.log(result)
}
run();{
"_templateId": "<string>",
"_environmentId": "<string>",
"_messageTemplateId": "<string>",
"_organizationId": "<string>",
"_notificationId": "<string>",
"_subscriberId": "<string>",
"createdAt": "<string>",
"content": {
"type": "text",
"content": "<string>",
"url": "<string>",
"styles": {
"textAlign": "left"
}
},
"transactionId": "<string>",
"channel": "in_app",
"read": true,
"seen": true,
"cta": {
"data": {
"url": "<string>"
},
"type": "redirect",
"action": {
"status": "pending",
"buttons": [
{
"type": "primary",
"content": "<string>",
"resultContent": "<string>"
}
],
"result": {
"payload": {},
"type": "primary"
}
}
},
"status": "sent",
"errorId": "<string>",
"errorText": "<string>",
"payload": {},
"overrides": {},
"_id": "<string>",
"subscriber": {
"subscriberId": "<string>",
"_organizationId": "<string>",
"_environmentId": "<string>",
"deleted": true,
"createdAt": "<string>",
"updatedAt": "<string>",
"_id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"email": "<string>",
"phone": "<string>",
"avatar": "<string>",
"locale": "<string>",
"channels": [
{
"providerId": "slack",
"credentials": {
"webhookUrl": "<string>",
"channel": "<string>",
"deviceTokens": [
"<string>"
],
"alertUid": "<string>",
"title": "<string>",
"imageUrl": "<string>",
"state": "<string>",
"externalUrl": "<string>"
},
"_integrationId": "<string>",
"integrationIdentifier": "<string>"
}
],
"isOnline": true,
"lastOnlineAt": "<string>",
"__v": 123
},
"template": {
"name": "<string>",
"description": "<string>",
"active": true,
"draft": true,
"preferenceSettings": {
"email": true,
"sms": true,
"in_app": true,
"chat": true,
"push": true
},
"critical": true,
"tags": [
"<string>"
],
"steps": [
{
"_id": "<string>",
"uuid": "<string>",
"name": "<string>",
"_templateId": "<string>",
"active": true,
"shouldStopOnFail": true,
"template": {},
"filters": [
{
"isNegated": true,
"type": "BOOLEAN",
"value": "AND",
"children": [
{
"field": "<string>",
"value": "<string>",
"operator": "LARGER",
"on": "subscriber"
}
]
}
],
"_parentId": {},
"metadata": {
"type": "regular",
"amount": 123,
"unit": "seconds",
"digestKey": "<string>",
"backoff": true,
"backoffAmount": 123,
"backoffUnit": "seconds",
"updateMode": true
},
"replyCallback": {},
"variants": {
"_id": "<string>",
"uuid": "<string>",
"name": "<string>",
"_templateId": "<string>",
"active": true,
"shouldStopOnFail": true,
"template": {},
"filters": [
{
"isNegated": true,
"type": "BOOLEAN",
"value": "AND",
"children": [
{
"field": "<string>",
"value": "<string>",
"operator": "LARGER",
"on": "subscriber"
}
]
}
],
"_parentId": {},
"metadata": {
"type": "regular",
"amount": 123,
"unit": "seconds",
"digestKey": "<string>",
"backoff": true,
"backoffAmount": 123,
"backoffUnit": "seconds",
"updateMode": true
},
"replyCallback": {}
}
}
],
"_organizationId": "<string>",
"_creatorId": "<string>",
"_environmentId": "<string>",
"triggers": [
{
"type": "event",
"identifier": "<string>",
"variables": [
{
"name": "<string>"
}
],
"subscriberVariables": [
{
"name": "<string>"
}
]
}
],
"_notificationGroupId": "<string>",
"deleted": true,
"deletedAt": "<string>",
"deletedBy": "<string>",
"_id": "<string>",
"_parentId": "<string>",
"notificationGroup": {
"name": "<string>",
"_environmentId": "<string>",
"_organizationId": "<string>",
"_id": "<string>",
"_parentId": "<string>"
},
"data": {},
"workflowIntegrationStatus": {}
},
"templateIdentifier": "<string>",
"lastSeenDate": "<string>",
"lastReadDate": "<string>",
"subject": "<string>",
"email": "<string>",
"phone": "<string>",
"directWebhookUrl": "<string>",
"providerId": "<string>",
"deviceTokens": [
"<string>"
],
"title": "<string>",
"_feedId": "<string>"
}Authorization field like the example shown below:E.g ApiKey 18d2e625f05d80eAPI key authentication. Allowed headers-- "Authorization: ApiKey <api_key>".
Created
in_app, email, sms, chat, push Show child attributes
redirect Show child attributes
pending, done sent, error, warning The payload that was used to send the notification trigger
Provider specific overrides used when triggering the notification
Show child attributes
The internal identifier you used to create this subscriber, usually correlates to the id the user in your systems
The internal id novu generated for your subscriber, this is not the subscriberId matching your query. See subscriberId for that
Channels settings for subscriber
Show child attributes
The provider identifier for the credentials
slack, discord, msteams, mattermost, ryver, zulip, grafana-on-call, getstream, rocket-chat, whatsapp-business, fcm, apns, expo, one-signal, pushpad, push-webhook, pusher-beams Credentials payload for the specified provider
Show child attributes
Webhook url used by chat app integrations. The webhook should be obtained from the chat app provider.
Channel specification for Mattermost chat notifications
Contains an array of the subscriber device tokens for a given provider. Used on Push integrations
alert_uid for grafana on-call webhook payload
title to be used with grafana on call webhook
image_url property fo grafana on call webhook
state property fo grafana on call webhook
link_to_upstream_details property fo grafana on call webhook
Id of the integration that is used for this channel
The integration identifier
Show child attributes
Show child attributes
Show child attributes
BOOLEAN, TEXT, DATE, NUMBER, STATEMENT, LIST, MULTI_LIST, GROUP AND, OR Show child attributes
LARGER, SMALLER, LARGER_EQUAL, SMALLER_EQUAL, EQUAL, NOT_EQUAL, ALL_IN, ANY_IN, NOT_IN, BETWEEN, NOT_BETWEEN, LIKE, NOT_LIKE, IN subscriber, payload Show child attributes
regular, backoff seconds, minutes, hours, days, weeks, months seconds, minutes, hours, days, weeks, months Show child attributes
Show child attributes
BOOLEAN, TEXT, DATE, NUMBER, STATEMENT, LIST, MULTI_LIST, GROUP AND, OR Show child attributes
LARGER, SMALLER, LARGER_EQUAL, SMALLER_EQUAL, EQUAL, NOT_EQUAL, ALL_IN, ANY_IN, NOT_IN, BETWEEN, NOT_BETWEEN, LIKE, NOT_LIKE, IN subscriber, payload Show child attributes
regular, backoff seconds, minutes, hours, days, weeks, months seconds, minutes, hours, days, weeks, months Show child attributes
event Was this page helpful?