Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

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.

Side
Library
What it does

Backend

Sends an event after the business change commits

UI

Renders Inbox and reads that subscriber's inbox

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.

#
Step
Where

1

Pick the event keys and the recipient for each

2

Create one workflow per event on the notification provider

3

Install the connector and map each event key in NOTIFICATION_WORKFLOWS

4

Call send after the business change commits

5

Install the client and build the session on the UI server

6

Render Inbox with the same subscriber id

7

Check that one event reaches the bell

Plan the events

Decide these before you write code:

Decision
Rule

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.

Variable
Notes

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 try and skip the send on ImportError, 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.

Setting
Public to the browser
Meaning

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:

  1. Read preferred_username from the access token. That is subscriberId. For a registrant portal, use person:{internal_record_id} instead.

  2. When NOTIFICATION_SECRET_KEY is set, compute HMAC-SHA256 of that id as hex. That is subscriberHash.

  3. Pass the public values with it: NOTIFICATION_PROVIDER, NOTIFICATION_APPLICATION_IDENTIFIER, NOTIFICATION_BACKEND_URL, and NOTIFICATION_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

Mistake
Effect
Fix

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

  1. Set NOTIFICATION_ENABLED=true and map one event.

  2. Trigger the business action as a user whose inbox you can open.

  3. Check the service log for Sending event ... workflow ... to recipient_id=.... A line that says Skipping event means the switch is off or the key is not mapped.

  4. Open the UI as that user. The bell shows the unread count, and the new notification arrives without a reload.

  5. 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

Last updated

Was this helpful?