How do I use my Discord Integration

Hello,

We will soon develop bubbles dedicated to the Discord Integration.

For now, this topic will explain you how to use your integration in order to create notifications into a Discord channel.

Just after integrating Discord on your bot, three data keys starting with “dc_” appears:


The ones we will use in this presentation are the access token and the guild id.

Here’s the API bubble you should make in order to list all your discord channel ids.


https://api.ideta.io/api/receive-message/-MuNtoLt0vcEApMhvqt-/{{dc_guild_id}}?action=list
Authorization: Bearer {{dc_access_token}};

The response is a list of channel objects, their main informations are their names, their ids and their types (text channels have 0 as type number).

Create this list of objects

Then store the data as below (in your API bubble).
Capture d’écran 2022-04-04 à 11.24.27

Here’s the result (you can find in test or with your livechat)
Capture d’écran 2022-04-04 à 11.36.17

Note, if your goal is only to know the id of your channel, you can also make the get request with Postman. Having the complete list in interesting if you want to choose which list you’d like to use depending on the conversation on your chatbot.

Also, if you want to collect more information about your channels, here’s how is build the channel object list the discord API provides:
[{
“id”: “163283729472354”,
“last_message_id”: “9283682374028”,
“type”: 0,
“name”: “général”,
“position”: 0,
“parent_id”: “92391742947263”,
“topic”: null,
“guild_id”: “387167293271682”,
“permission_overwrites”: [ ],
“nsfw”: false,
“rate_limit_per_user”: 0
}]

Now you got your ids, you need to use it in order to send a message to the channel you want.

Here’s the request:
Capture d’écran 2022-04-04 à 11.43.47

Endpoint:
https://api.ideta.io/api/receive-message/-MuNtoLt0vcEApMhvqt-/{{dc_guild_id}}?action=message

Headers:
Content-Type: application/json;
Authorization: Bearer {{dc_access_token}};

Request body:
{
“target_id”:"{{targetchannel_id}}",
“content”: “{{content}}”, //(not mandatory, if you want to send embedded messages)
“tts”: false,
“embeds”: [{
“title”: “{{title}}”,
“description”: “{{description}}”
}]
}

Example:

Now you know how to create notifications into your discord channel using bots.

Thanks, if you have any questions do not hesitate.