Integrating a new service
How a new application sends a notification from its backend and shows the inbox in its UI. Both sides use the same subscriber id.
A new application uses both libraries in OpenG2P/notifications. The backend sends. The UI shows the inbox. They do not import each other.
The subscriber id must be the same on both sides. Staff is the Keycloak username (preferred_username). A registrant is person:{internal_record_id}. See Identity.
Novu install, workflow copy, and email or SMS credentials are in Novu. This page does not repeat them.
Steps at a glance
Do these in order. Each step names the section that covers it.
Plan the events
Decide these before you write code:
Event key
Dotted and lowercase, for example grievance.assigned. One key per business moment
Recipient
Staff (preferred_username) or registrant (registrant_id(internal_record_id)). One person per Recipient. Use send_bulk for many people
Channels
Set on the notification provider workflow, not in Python. In-app needs no external provider. Email and SMS need an integration on the provider
Payload
Every field the template reads as {{payload.*}}. Add ids for links and friendly names for the copy. Send a missing value as empty, not as an absent key
The existing Registry and AWE events are in Workflows and payloads. Reuse their field names where the meaning is the same.
Backend
Install the connector in the service that owns the business change:
Images that build from source install it from git. See Install.
Set these on the service. The full list and defaults are in Connector.
NOTIFICATION_ENABLED
false skips every send
NOTIFICATION_PROVIDER
novu by default
NOTIFICATION_PROVIDER_URL
In-cluster API URL of the notification provider
NOTIFICATION_PROVIDER_API_KEY
Secret. Stays on the server
NOTIFICATION_WORKFLOWS
JSON map of event key to workflow id. An event that is not listed is not sent
For example:
After the business change commits, call send with the event key, the entity id, the payload, and a Recipient:
Do not pass a channel.
Send after the commit, so a rolled-back change does not notify.
Log a failed send. Do not fail the business request.
If the package may be missing in some images, import it inside a
tryand skip the send onImportError, as Registry and AWE do.
recipient_id on that Recipient is the subscriber id the UI will open. The rules for async code, bulk sends, and notification ids are in Implementing a send.
User interface
Install the client in the UI app:
The React page renders Inbox. The server builds the session. Props and packaging are in Client.
Give the UI server these settings. The names below are the ones the registry staff UI uses. Another app can use its own names, as long as the values reach Inbox.
NOTIFICATION_PROVIDER
Yes
Client adapter name. novu by default
NOTIFICATION_APPLICATION_IDENTIFIER
Yes
Application identifier from the notification provider environment
NOTIFICATION_BACKEND_URL
Yes
Public API URL of the notification provider
NOTIFICATION_WEBSOCKET_URL
Yes
Public WebSocket URL of the notification provider
NOTIFICATION_SECRET_KEY
No
Server-only HMAC secret
On the server, after login:
Read
preferred_usernamefrom the access token. That issubscriberId. For a registrant portal, useperson:{internal_record_id}instead.When
NOTIFICATION_SECRET_KEYis set, computeHMAC-SHA256of that id as hex. That issubscriberHash.Pass the public values with it:
NOTIFICATION_PROVIDER,NOTIFICATION_APPLICATION_IDENTIFIER,NOTIFICATION_BACKEND_URL, andNOTIFICATION_WEBSOCKET_URL.
Then render the inbox in a client component. Do not render it until provider, applicationIdentifier, and subscriberId are set. The full component, the theme, and the localization props are in Render the inbox.
The browser then talks to the notification provider for the list and the live socket. The UI server does not proxy those calls.
The registry staff UI is one example of this split: getNotificationHmac on the server, NotificationInbox in the page.
Common mistakes
Different subscriber id on the backend and in the UI (for example an email, or a Keycloak sub)
The send succeeds. The bell stays empty
Use preferred_username for staff and person:{id} for registrants on both sides
NOTIFICATION_SECRET_KEY sent to the browser
Anyone can forge a subscriberHash and read another inbox
Keep it on the server. Send only the hash
NOTIFICATION_SECRET_KEY used as NOTIFICATION_PROVIDER_API_KEY, or the reverse
Sends fail, or the inbox is rejected
They are two different secrets. See Secret
In-cluster URL (http://commons-novu-api:3000) passed as backendUrl
The browser cannot reach it
Use the public https:// API and WebSocket hosts
Event key missing from NOTIFICATION_WORKFLOWS
The connector returns skipped and nothing is sent
Add the key. See Connector
Workflow id with a dot
The provider cannot find the workflow
Replace . and _ with -, for example grievance-assigned
Payload field the template reads is not sent
The copy renders with a blank
Send every field the template uses, empty if there is no value
Link in the payload with no host
The button opens a broken URL
Put the public UI origin in the payload, as staff_portal_base_url does for Registry and AWE. See Deployment
Verify
Set
NOTIFICATION_ENABLED=trueand map one event.Trigger the business action as a user whose inbox you can open.
Check the service log for
Sending event ... workflow ... to recipient_id=.... A line that saysSkipping eventmeans the switch is off or the key is not mapped.Open the UI as that user. The bell shows the unread count, and the new notification arrives without a reload.
For email and SMS, check the delivery log in the notification provider dashboard.
If one event stays silent, walk the checklist in When a send does not happen.
Next
Add Helm values and secrets for your chart: Deployment.
Replace the notification provider: Switch provider for the backend and Switch provider for the UI.
Last updated
Was this helpful?