novu
novu copied to clipboard
[NV-1247] 🚀 Feature: Add websocket event for new notifications
🔖 Feature description
This feature would resolve some issues that you might encounter when implementing some custom functionality on the frontend. In addition to the existing unseen_count_changed
event, I propose to add another event such as notification_received
which would contain all the relevant data for a new notification as follows:
{
_id: "_id",
_templateId: "_templateId",
_environmentId: "_environmentId",
_messageTemplateId: "_messageTemplateId",
_organizationId: "_organizationId",
_notificationId: "_notificationId",
_subscriberId: "_subscriberId",
subscriber: subscriber,
template: template,
templateIdentifier: "templateIdentifier",
createdAt: "createdAt",
content: "content",
transactionId: "transactionId",
channel: "channel",
seen: true,
email: "email",
phone: "phone",
directWebhookUrl: "directWebhookUrl",
providerId: "providerId",
deviceTokens: ["deviceTokens"],
title: "title",
lastSeenDate: "lastSeenDate",
cta: cta,
_feedId: "_feedId",
status: "status",
errorId: "errorId",
errorText: "errorText",
payload: payload,
overrides: overrides,
subject: "subject"
}
🎤 Why is this feature needed ?
While there are already nice solutions for displaying events in a UI such as the useNotifications hook and the Novu API, adding this event would give developers more flexibility when building their UIs. For example, you could reduce the load on the client by fetching events using the API, and then simply listen for new events by websocket and update the UI when appropriate.
✌️ How do you aim to achieve this?
By creating a new event that users can subscribe to and execute relevant logic when such an event is emitted.
🔄️ Additional Information
No response
👀 Have you spent some time to check if this feature request has been raised before?
- [X] I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- [X] I have read the Contributing Guidelines
Are you willing to submit PR?
Yes I am willing to submit a PR!
@SpencerMiller23 let me know if you want me to assign you to this one :)
@scopsy I will look into it when I have some spare time but feel free to assign to someone else in the meantime
Hey, @scopsy can you assign it to me, would love to work on it. 😊
Sure @Nabhag8848 thank you!
Hi @Nabhag8848 , need any inputs from the team?
Any updates with regards to this feature?