Skip to main content
Version: 1.3.x

Sending notifications

You can trigger notifications from Engagespot in two ways. One is to directly hardcode the notifications in your API call, or the second is to create templates in the Engagespot console and then trigger those templates via API. The latter is recommended because it allows you to decouple your notification content from the code.

Triggering hardcoded notifications

You can trigger hardcoded notifications using our REST API or a client library of your choice. Make sure to create the recipient/user before sending a notification to them. If you haven't created a user, read this guide first.

curl -X POST 'https://api.engagespot.co/v3/notifications' \
-H 'X-ENGAGESPOT-API-KEY: ENGAGESPOT_API_KEY' \
-H 'X-ENGAGESPOT-API-SECRET: ENGAGESPOT_SECRET_KEY' \
-H 'Content-Type: application/json' \
-d '{ "notification": { "title": "Rose accepted your friend request" }, "sendTo":{"recipients": ["unique-id-of-recipient-user"] } }'
info

When you trigger a hardcoded notification, the message will be sent across all channels enabled in your Engagespot console. You can override this configuration through the override property in the API request.

Sending notifications using third party plugins

Triggering templated notifications

To learn more about templates, read this guide first. To send a templated notification, the steps are exactly the same, except that you should replace the title field with templateIdentifier. For example:

import { EngagespotClient } from '@engagespot/node';

const client = EngagespotClient({
apiKey: 'ENGAGESPOT_API_KEY',
apiSecret: 'ENGAGESPOT_SECRET_KEY',
});

client.send({
notification: {
templateIdentifier: 'template-identifier-copied-from-engagespot-console',
},
sendTo: {
recipients: ['unique-id-of-recipient-user'],
},
});