N
Novu5mo ago
Kh. M-S.

Send notification to all subscribers

How do send notification to all subscribers from Web App panel?
9 Replies
Ask Inkeep
Ask Inkeep5mo ago
Hi @Kh. M-S., I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question. ----------------------------- While I generate an answer, here are some sources that might be helpful: * How to send web push notifications with FCM and Novu * How to Add Digest to In-App Notifications * How to send push notifications in an Android app (react native) with FCM and Novu * How to send push notifications to Flutter apps (Android & iOS) with FCM using Novu -----------------------------
Ask Inkeep
Ask Inkeep5mo ago
Answer To send notifications to all subscribers from the Web App panel, you can use Novu's Topic API. This allows you to create a topic, add all subscribers to it, and then send a notification to that topic. (1) Creating a Topic First, create a topic that will include all your subscribers:
await novu.topics.create({
key: 'all-subscribers',
name: 'All Subscribers',
});
await novu.topics.create({
key: 'all-subscribers',
name: 'All Subscribers',
});
Adding Subscribers to the Topic Next, add all your subscribers to this topic. You'll need to do this for each subscriber:
await novu.topics.addSubscribers('all-subscribers', {
subscribers: ['subscriber-id-1', 'subscriber-id-2', ...],
});
await novu.topics.addSubscribers('all-subscribers', {
subscribers: ['subscriber-id-1', 'subscriber-id-2', ...],
});
Sending a Notification to the Topic Finally, you can send a notification to all subscribers in the topic:
await novu.trigger('notification-template-name', {
to: [{ type: 'Topic', topicKey: 'all-subscribers' }],
payload: {
title: 'Notification Title',
body: 'Notification Body',
},
});
await novu.trigger('notification-template-name', {
to: [{ type: 'Topic', topicKey: 'all-subscribers' }],
payload: {
title: 'Notification Title',
body: 'Notification Body',
},
});
This method allows you to send notifications to multiple users simultaneously without having to specify each subscriber individually. Remember to replace 'notification-template-name' with the actual name of your notification template, and adjust the payload according to your needs. If you need more detailed information or have specific questions about implementation, I suggest clicking on the "Ask for help" button to tag a team member for a more thorough review of your question.
Ask Inkeep
Ask Inkeep5mo ago
Feel free to tag @Ask Inkeep with additional questions. Glad I could be helpful. Feel free to create a new thread with any new questions you may have.
Pawan Jain
Pawan Jain5mo ago
Hey @Kh. M-S. We have broadcast api which will trigger the workflow to all subscriber in one environment You will have to either hit the this api using our api reference send option or use this in postman because currently it is not possible to do this operation from Novu UI
Pawan Jain
Pawan Jain5mo ago
Novu
Broadcast event to all - Novu
Trigger a broadcast event to all existing subscribers, could be used to send announcements, etc. In the future could be used to trigger events to a subset of subscribers based on defined filters.
Kh. M-S.
Kh. M-S.OP5mo ago
@Pawan Jain does it work for self-hosted vetsion? I get error "API Key not found". Although I can trigger notifications from Web App. Maybe I need write url of my server in the bridgeUrl? @Pawan Jain I tried also in Postman. But I get the same error
Novu_Bot
Novu_Bot5mo ago
@Kh. M-S., you just advanced to level 5!
Kh. M-S.
Kh. M-S.OP5mo ago
@Pawan Jain I did it in Postman. So if I use self-hosted version I can do it only in Postman? I cannot change url in your api to mine. For me it is ok to use Postman. But if it could be in your api it would be better.
Pawan Jain
Pawan Jain5mo ago
@Kh. M-S. Sure I will check if it is possible to use localhost / custom url on api reference
Want results from more Discord servers?
Add your server