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.
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.
- Javascript Core
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.
- Node
- cURL
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"
}
}'
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
-
Go to the channel you want to add the webhook to (you need to be an admin of the discord server).
-
Right-click the channel and select “Edit Channel”.
-
Integrations -> Webhooks -> New Webhook
-
Copy the webhook URL.
-
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.