> ## Documentation index
> Fetch the complete documentation index at: https://novu.docs7.io/llms.txt
> Ask it with GET https://novu.docs7.io/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.

# Discord Chat Integration with Novu

> Connect Discord to Novu to send chat notifications through workflows. Create a bot, generate the webhook URL, and store credentials for delivery to channels.

When using Discord, you will have to store the integration credentials within the subscriber entity. Discord supports two ways to do this:

1. Using the **Discord Webhook** integration.
2. Using the **Discord Bot** integration.

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:

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 subscriber entity. Doing this ensures that Novu knows where (in which discord channel) to send the notification to. Here's how to do it:

<Tabs>
  <Tab title="Node.js">
```typescript
import { Novu } from '@novu/api';
import { ChatOrPushProviderEnum } from "@novu/api/models/components";

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",
        },
    )
```
  </Tab>
  <Tab title="Go">
```go
import (
    "context"
    "os"

    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>',
        ),
    ),
);
```
  </Tab>
  <Tab title=".NET">
```csharp
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;

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();
```
  </Tab>
  <Tab title="cURL">
```bash
curl -L -X PUT 'https://api.novu.co/v1/subscribers/<SUBSCRIBER_ID>/credentials' \
-H 'Content-Type: application/json' \
-H 'Authorization: ApiKey <NOVU_SECRET_KEY>' \
-d '{
  "providerId": "discord",
  "credentials": {
    "webhookUrl": "<WEBHOOK_URL>"
  },
  "integrationIdentifier": "discord-MnGLxp8uy"
}'
```
  </Tab>
</Tabs>

Checkout the [API reference](/api-reference/subscribers/update-provider-credentials) 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.
- The third parameter is the credentials object. In this case, we use the `webhookUrl` property to specify the webhook URL generated in the previous step.

6. You are all set up and ready to send your first chat message via our `@novu/api` package or directly using the REST API in the channel you chose on your discord server.
