docs/platform/integrations/chat/mattermost.mdx
When using Mattermost, you will have to store the integration credentials within the subscriber entity. Mattermost supports two ways to do this:
To integrate Mattermost with your application using the Mattermost Webhook integration, follow these steps:
Once you have the webhook URL, you can store it in the subscriber entity in your application. This will allow you to send notifications to Mattermost using the following code:
<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.Mattermost, integrationIdentifier: "mattermost-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.MATTERMOST,
"credentials": {"webhookUrl": "<WEBHOOK_URL>"},
"integration_identifier": "mattermost-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.ChatOrPushProviderEnumMattermost, IntegrationIdentifier: novugo.String("mattermost-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::Mattermost,
integrationIdentifier: 'mattermost-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.Mattermost, IntegrationIdentifier = "mattermost-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.MATTERMOST)
.integrationIdentifier("mattermost-MnGLxp8uy")
.credentials(ChannelCredentials.builder()
.webhookUrl("<WEBHOOK_URL>")
.build())
.build())
.call();
Send a notification to mattermost using the subscriber ID and workflow ID via @novu/api sdk
const novu = new Novu({ secretKey: "<NOVU_SECRET_KEY>" });
await novu.trigger({ workflowId: "workflowId", to: { subscriberId: "subscriberId", }, payload: { "message": "This is a notification from my application!" }, });
</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.trigger(trigger_event_request_dto=novu_py.TriggerEventRequestDto(
workflow_id="workflowId",
to={"subscriber_id": "subscriberId"},
payload={
"message": "This is a notification from my application!"
},
))
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.Trigger(context.Background(), components.TriggerEventRequestDto{ WorkflowID: "workflowId", To: components.CreateToSubscriberPayloadDto(components.SubscriberPayloadDto{ SubscriberID: "subscriberId", }), Payload: map[string]any{ "message": "This is a notification from my application!" }, }, nil)
</Tab>
<Tab title="PHP">
```php
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()->setSecurity('<NOVU_SECRET_KEY>')->build();
$sdk->trigger(
triggerEventRequestDto: new Components\TriggerEventRequestDto(
workflowId: 'workflowId',
to: new Components\SubscriberPayloadDto(subscriberId: 'subscriberId'),
payload: {
"message": "This is a notification from my application!"
},
),
);
var sdk = new NovuSDK(secretKey: "<NOVU_SECRET_KEY>");
await sdk.TriggerAsync(triggerEventRequestDto: new TriggerEventRequestDto() { WorkflowId = "workflowId", To = To.CreateSubscriberPayloadDto(new SubscriberPayloadDto() { SubscriberId = "subscriberId" }), Payload = { "message": "This is a notification from my application!" }, });
</Tab>
<Tab title="Java">
```java
import co.novu.Novu;
import co.novu.models.components.*;
Novu novu = Novu.builder().secretKey("<NOVU_SECRET_KEY>").build();
novu.trigger()
.body(TriggerEventRequestDto.builder()
.workflowId("workflowId")
.to(To2.of(SubscriberPayloadDto.builder().subscriberId("subscriberId").build()))
.payload({
"message": "This is a notification from my application!"
})
.build())
.call();