IntegrationsNovu (Notifications)

Novu (Notifications)

Novu is the notification platform that fronts every outbound message HiveCFM sends to a contact. Hive never talks to SES, a carrier, or an SMTP host directly. It creates a Novu workflow, triggers it for a subscriber, and lets Novu resolve the provider.

That indirection is the point: swapping the email or SMS vendor is a change inside Novu, not a change in hivecfm-core.

Novu is sometimes written “NOVA” in tickets and hallway conversation. There is no component called NOVA. Everything below is novu: the IntegrationType, the env var prefix, the lib/novu/ directory.

Config resolution

Every Novu call resolves credentials the same way, per environment, on every request. There is no cache.

  1. getIntegrationByType(environmentId, "novu") reads the Integration row for this environment. If config.key.apiKey and config.key.apiUrl are both present, they win.
  2. Otherwise fall back to NOVU_API_KEY / NOVU_API_URL from the process env.
  3. If neither resolves, behavior splits by caller: contact sync returns silently, anything campaign-facing throws "Novu is not configured..." from getRequiredNovuConfig.

This is what makes bring-your-own-Novu possible. A tenant can point one environment at their own Novu instance without touching deployment config.

Where a tenant sets their own

/environments/:environmentId/workspace/integrations/novu

The page redirects read-only members away (isReadOnly). Saving or testing requires organization owner or manager, or readWrite on the project team. Two server actions back it:

ActionWhat it does
testNovuConnectionActionGET {apiUrl}/v1/subscribers?limit=1 with the entered key, so credentials are validated before they are stored
listNovuIntegrationsActionGET /v1/integrations/active, listing the channels and providers actually live in that Novu instance

Saving writes the Integration row through createOrUpdateIntegrationAction.

⚠️

Integration.config is a plain Prisma Json column with no application-level encryption. A tenant’s Novu API key is stored in cleartext in Postgres; the UI masks it on display only. Treat database dumps accordingly.

Provisioning

Tenant creation (POST /api/v1/management/tenants) runs a saga whose NOVU_CONFIGURED step calls provisionNovuForTenant. That step writes the global credentials into an Integration row for every environment in the new tenant. It does not create a separate Novu instance, or a separate Novu environment.

Out of the box, then, per-tenant Novu isolation is bookkeeping, not separation. It becomes real isolation only when someone overrides the credentials in the UI. If IS_NOVU_CONFIGURED is false the step logs a warning and continues: provisioning degrades, it does not fail.

Contacts become subscribers

A HiveCFM Contact maps to a Novu subscriber in modules/ee/contacts/lib/novu-sync.ts.

  • subscriberId is the userId attribute, falling back to email. A contact with neither is skipped with a warning.
  • These attributes map onto native Novu subscriber fields: email, firstName, lastName, phone, avatar, locale, timezone.
  • Every other attribute is nested under subscriber.data, so custom CRM fields survive the trip and stay addressable in Novu templates.
Entry pointNovu endpointFires on
syncContactToNovuPOST /v1/subscribersSingle contact created or upserted through the API
syncBulkContactsToNovuPOST /v1/subscribers/bulkBulk contact API, chunked at 500 per request
syncCSVContactsToNovuPOST /v1/subscribers/bulkCSV upload, chunked at 500 per request
deleteSubscriberFromNovuDELETE /v1/subscribers/:idContact deletion
⚠️

Every sync function is best-effort: it logs and swallows errors, and never throws. A contact write always succeeds in HiveCFM even when Novu is down or rejecting. There is no reconciliation job, so an outage produces silent drift between the contact table and the Novu subscriber list, and nothing downstream notices.

The API surface Hive calls

lib/novu/service.ts is the only place that speaks Novu. Auth is one header on every call: Authorization: ApiKey <key>.

FunctionNovu endpointNotes
listActiveIntegrationsGET /v1/integrations/activePowers the channel list in the settings UI
createEmailWorkflowPOST /v2/workflowsOne workflow per campaign. Sends editorType: "html" with disableOutputSanitization: true so the Hive-rendered email survives intact
createSmsWorkflowPOST /v2/workflowsSingle sms step
triggerWorkflowPOST /v1/events/triggerAccepts overrides for email / phone
triggerBulkWorkflowPOST /v1/events/trigger/bulkOne event per subscriber in a single request
deleteWorkflowDELETE /v2/workflows/:id
sendSmsMessagePOST /v1/events/triggerTriggers the shared campaign-sms-outbound workflow with a {{message}} payload
getWorkflowMessagesGET /v1/messagesPaginated; see the limits below

Workflow CRUD is Novu v2. Triggers, subscribers, integrations, and messages are v1. The mix matches Novu’s own API split; it is not a migration left half-done.

🚫

sendSmsMessage triggers a workflow named campaign-sms-outbound, and no code creates it. It must already exist in the target Novu instance or every SMS send fails at trigger time. Put it on the checklist for standing up a new Novu instance, and for any tenant that brings their own.

Email and SMS campaigns

The dispatch sequence has its own page: Campaign Send Flow. Short version: the email branch registers one workflow per campaign and triggers it per contact in batches of five; the SMS branch opens a session and sends question one.

Inbound SMS

POST /api/v1/novu/sms-inbound is how an SMS answer gets back in. It is the only inbound Novu route.

The handler is deliberately tolerant about payload shape, because field names depend on the SMS provider sitting behind Novu. It takes the phone number from any of subscriberId, phone, from, subscriber.subscriberId, payload.phone, and the text from any of payload.message, message, text, payload.text, payload.body.

Behavior worth knowing before you debug it:

  • No signature verification. The route checks no HMAC, no API key, no shared secret.
  • An unknown phone number returns 200 {"ignored": true}, not an error. A missing session is a normal outcome.
  • Answers are written incrementally to the Response row with finished: false, so a half-finished SMS survey is visible in the UI.
  • On the last question the handler marks the response finished, fires responseUpdated and responseFinished into the pipeline, sends the survey’s first ending headline as thank-you text, and flips CampaignSend.status to sent.
  • Invalid answers are re-prompted when the survey has invalidResponseCard.enabled, capped by maxAttempts (0 means unlimited), and every rejection is written to the audit log.
🚫

SMS sessions live in a module-level Map in lib/campaign/sms-session.ts with a one-hour TTL. They are per-process. Any replica count above one drops replies that land on the wrong instance, and every deploy or restart abandons every in-flight SMS survey. Treat multi-replica SMS as unsupported until this moves to Redis.

Delivery analytics, and what they prove

getWorkflowStats derives campaign numbers from GET /v1/messages. Read the limits before quoting a number to a client.

LimitConsequence
Channel is hardcoded to emailSMS campaigns report zero messages
Novu’s templateId filter is unreliable, so Hive re-filters client-side on templateIdentifierResults are correct, but more pages are fetched than necessary
Hard stop at 50 pages of 100Campaigns above 5,000 messages report truncated stats, with no warning in the UI
status === "sent" increments both sent and delivered”Delivered” means Novu accepted the send, not that anything reached an inbox
seen / read are passed through from NovuOnly as reliable as the tracking pixel
⚠️

There is no bounce or complaint webhook anywhere in hivecfm-core. CampaignSend.status is set from the outcome of the synchronous trigger call, so a message that was accepted and then bounced stays sent forever. Asynchronous provider feedback is never reconciled.

Environment variables

VariableRequiredPurpose
NOVU_API_KEYfor any Novu featureSent as Authorization: ApiKey <key>
NOVU_API_URLrecommendedBase URL of the Novu API including its /api suffix. A deployed default is baked into lib/constants.ts; set this explicitly per environment rather than inheriting it

Both are optional in the env schema (lib/env.ts). IS_NOVU_CONFIGURED is just both being truthy, and it gates provisioning and the env-var fallback.

Where to look in the code

  • hivecfm-core/apps/web/lib/novu/service.ts — every outbound Novu call.
  • hivecfm-core/apps/web/lib/novu/tenant-provisioning.ts — provisionNovuForTenant, deprovisionNovuForTenant.
  • hivecfm-core/apps/web/modules/ee/contacts/lib/novu-sync.ts — contact-to-subscriber mapping, four sync entry points.
  • hivecfm-core/apps/web/app/api/v1/novu/sms-inbound/route.ts — inbound SMS state machine.
  • hivecfm-core/apps/web/lib/campaign/sms-session.ts — the in-memory session map.
  • hivecfm-core/apps/web/app/(app)/environments/[environmentId]/workspace/integrations/novu/ — settings page, NovuWrapper, and the two server actions.
  • hivecfm-core/packages/types/integration/novu.ts — ZIntegrationNovu config schema.
  • hivecfm-core/packages/types/campaign.ts — ZCampaignNovuStats, ZCampaignNovuMessage.

HiveCFM Developer Hub — internal team guide