docs/platform/integrations/chat/discord.mdx
When using Discord, you will have to store the integration credentials within the subscriber entity. Discord supports two ways to do this:
Right now, Novu only supports the Discord Webhook integration. This approach has been because the easiest way to set it up is when you have a predefined destination for where the notifications should be sent. It's particularly useful for notifying a specific channel about updates.
Quickstart:
To get started with using Novu's Discord Webhook integration, you need a 'webhook token'. Here's how you can generate the same for testing purposes:
const novu = new Novu({ secretKey: "<NOVU_SECRET_KEY>" });
await novu.subscribers.credentials.update( { providerId: ChatOrPushProviderEnum.Discord, integrationIdentifier: "discord-MnGLxp8uy", credentials: { webhookUrl: "<WEBHOOK_URL>", }, }, "subscriberId" );
</Tab>
<Tab title="Python">
```python
import os
import novu_py
from novu_py import Novu
with Novu(secret_key=os.getenv("NOVU_SECRET_KEY", "")) as novu:
novu.subscribers.credentials.update(
subscriber_id="subscriberId",
update_subscriber_channel_request_dto={
"provider_id": novu_py.ChatOrPushProviderEnum.DISCORD,
"credentials": {"webhookUrl": "<WEBHOOK_URL>"},
"integration_identifier": "discord-MnGLxp8uy",
},
)
novugo "github.com/novuhq/novu-go"
"github.com/novuhq/novu-go/models/components"
)
s := novugo.New(novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")))
res, err := s.Subscribers.Credentials.Update(context.Background(), "subscriberId", components.UpdateSubscriberChannelRequestDto{ ProviderID: components.ChatOrPushProviderEnumDiscord, IntegrationIdentifier: novugo.String("discord-MnGLxp8uy"), Credentials: components.ChannelCredentials{ WebhookURL: novugo.String("<WEBHOOK_URL>"), }, }, nil)
</Tab>
<Tab title="PHP">
```php
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()->setSecurity('<NOVU_SECRET_KEY>')->build();
$sdk->subscribersCredentials->update(
subscriberId: 'subscriberId',
updateSubscriberChannelRequestDto: new Components\UpdateSubscriberChannelRequestDto(
providerId: Components\ChatOrPushProviderEnum::Discord,
integrationIdentifier: 'discord-MnGLxp8uy',
credentials: new Components\ChannelCredentials(
webhookUrl: '<WEBHOOK_URL>',
),
),
);
var sdk = new NovuSDK(secretKey: "<NOVU_SECRET_KEY>");
await sdk.Subscribers.Credentials.UpdateAsync( subscriberId: "subscriberId", updateSubscriberChannelRequestDto: new UpdateSubscriberChannelRequestDto() { ProviderId = ChatOrPushProviderEnum.Discord, IntegrationIdentifier = "discord-MnGLxp8uy", Credentials = new ChannelCredentials() { WebhookUrl = "<WEBHOOK_URL>", }, });
</Tab>
<Tab title="Java">
```java
import co.novu.Novu;
import co.novu.models.components.*;
import java.util.List;
Novu novu = Novu.builder().secretKey("<NOVU_SECRET_KEY>").build();
novu.subscribers().credentials().update()
.subscriberId("subscriberId")
.body(UpdateSubscriberChannelRequestDto.builder()
.providerId(ChatOrPushProviderEnum.DISCORD)
.integrationIdentifier("discord-MnGLxp8uy")
.credentials(ChannelCredentials.builder()
.webhookUrl("<WEBHOOK_URL>")
.build())
.build())
.call();
Checkout the API reference for more details.
subscriberId is a custom identifier used when identifying your users within the Novu platform.providerId is a unique provider identifier. We recommend using our ChatOrPushProviderEnum to specify the provider.webhookUrl property to specify the webhook URL generated in the previous step.@novu/api package or directly using the REST API in the channel you chose on your discord server.