Back to Novu

Zulip Chat Integration with Novu

docs/platform/integrations/chat/zulip.mdx

3.18.05.5 KB
Original Source

Zulip does not need any API Key or client ID to push messages in it. All it needs is the webhook URL of the channel you want to send messages to. That itself acts as the credential.

Similar to Discord, the credential for this provider needs to be stored in the subscriber entity.

Getting a Zulip webhook URL

  • Sign up or Login to your Zulip account.

  • Click on the Settings icon in the top right corner of the screen, and then click "Personal settings" from the drop-down menu.

  • Click "Add a new bot" button in "Bots" tab.

  • Set bot type as "Incoming webhook".

  • Click the small link icon to generate webhook URL for provider. Set Integration as Slack compatible webhook, choose your channel and copy webhook URL.

Connecting our subscribers to Zulip

The URL generated above will be the target channel of a subscriber that you want to integrate with. To make this connection, you have to:

  1. Copy the URL that you generated above

  2. Update the subscriber credentials with this URL using the Zulip provider id. You can do this step by using the @novu/api library, as shown below:

Update credential webhookUrl

<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.Zulip, integrationIdentifier: "zulip-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.ZULIP,
            "credentials": {"webhookUrl": "<WEBHOOK_URL>"},
            "integration_identifier": "zulip-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.ChatOrPushProviderEnumZulip, IntegrationIdentifier: novugo.String("zulip-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::Zulip,
        integrationIdentifier: 'zulip-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.Zulip, IntegrationIdentifier = "zulip-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.ZULIP)
            .integrationIdentifier("zulip-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": "zulip", "credentials": { "webhookUrl": "<WEBHOOK_URL>" }, "integrationIdentifier": "zulip-MnGLxp8uy" }' ``` </Tab> </Tabs>
  • 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 Zulip channel webhook URL or by calling the Update Subscriber Credentials endpoint on Novu API. Check endpoint details here.
  1. You are all set up and ready to send your first chat message via our `@novu/api package or directly using the REST API.