Skip to main content
Version: 1.3.x

Discord Integration Guide

To integrate Discord with Engagespot for notifications, you'll need to store integration credentials within the user's profile. This allows specific channels to receive updates seamlessly.

Unique Identifier

Each provider is identified by a unique identifier. Unique identifier of Discord provider is discord.

Enabling Discord Provider

To enable Discord provider, login to your Engagespot dashboard, goto Channels -> Discord and enable Discord Provider.

info

Discord uses discord attribute in your user's profile as the primary address to deliver the notifications. So make sure your user's profile has the discord attribute set.

How set discord attribute in user's profile.

You can add discord attributes to your user's profile either via REST API or our front-end libraries (For example - ReactJS or Core Javascript).

From front-end library

Make sure you have authenticated the front-end library properly.

const engagespotClient = new Engagespot('API_KEY', {
userId: '123e4567-e89b-12d3-a456-426614174000',
});

engagespotClient.setProfileAttributes({
discord: {
webhookUrl: 'your webhook token url',
},
});

This will add discor attribute to your user's (123e4567-e89b-12d3-a456-426614174000) profile.

From backend library or REST API

You can use the PUT method on /users end point or PUT method of /profile endpoint in the REST API to update your user's profile. Read API Docs for more information.

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

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

client.createOrUpdateUser('identifier', {
discord: {
webhookUrl: 'your webhook token url',
},
});
curl --location --request PUT 'https://api.engagespot.co/v3/users/{identifier}' \
--header 'X-ENGAGESPOT-API-KEY: ENGAGESPOT_API_KEY' \
--header 'X-ENGAGESPOT-API-SECRET: ENGAGESPOT_API_SECRET' \
--header 'Content-Type: application/json' \
--data-raw '{
"discord": {
"webhookUrl": "your webhook token url"
}
}'
info

Alternatively, you can use PATCH method on /profile endpoint which uses JSON Patch syntax to do complex operations on your Profile object.

Get Webhook Token for Discord

  1. Go to the channel you want to add the webhook to (you need to be an admin of the discord server).

  2. Right-click the channel and select “Edit Channel”.

  3. Integrations -> Webhooks -> New Webhook

  4. Copy the webhook URL.

  5. After obtaining the webhook URL in the previous step, you need to store it within the user's profile. Doing this ensures that Engagespot knows where (in which discord channel) to send the notification to.