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.
getIntegrationByType(environmentId, "novu")reads theIntegrationrow for this environment. Ifconfig.key.apiKeyandconfig.key.apiUrlare both present, they win.- Otherwise fall back to
NOVU_API_KEY/NOVU_API_URLfrom the process env. - If neither resolves, behavior splits by caller: contact sync returns silently, anything campaign-facing throws
"Novu is not configured..."fromgetRequiredNovuConfig.
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:
| Action | What it does |
|---|---|
testNovuConnectionAction | GET {apiUrl}/v1/subscribers?limit=1 with the entered key, so credentials are validated before they are stored |
listNovuIntegrationsAction | GET /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.
subscriberIdis theuserIdattribute, falling back toemail. 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 point | Novu endpoint | Fires on |
|---|---|---|
syncContactToNovu | POST /v1/subscribers | Single contact created or upserted through the API |
syncBulkContactsToNovu | POST /v1/subscribers/bulk | Bulk contact API, chunked at 500 per request |
syncCSVContactsToNovu | POST /v1/subscribers/bulk | CSV upload, chunked at 500 per request |
deleteSubscriberFromNovu | DELETE /v1/subscribers/:id | Contact 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>.
| Function | Novu endpoint | Notes |
|---|---|---|
listActiveIntegrations | GET /v1/integrations/active | Powers the channel list in the settings UI |
createEmailWorkflow | POST /v2/workflows | One workflow per campaign. Sends editorType: "html" with disableOutputSanitization: true so the Hive-rendered email survives intact |
createSmsWorkflow | POST /v2/workflows | Single sms step |
triggerWorkflow | POST /v1/events/trigger | Accepts overrides for email / phone |
triggerBulkWorkflow | POST /v1/events/trigger/bulk | One event per subscriber in a single request |
deleteWorkflow | DELETE /v2/workflows/:id | |
sendSmsMessage | POST /v1/events/trigger | Triggers the shared campaign-sms-outbound workflow with a {{message}} payload |
getWorkflowMessages | GET /v1/messages | Paginated; 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
Responserow withfinished: false, so a half-finished SMS survey is visible in the UI. - On the last question the handler marks the response finished, fires
responseUpdatedandresponseFinishedinto the pipeline, sends the survey’s first ending headline as thank-you text, and flipsCampaignSend.statustosent. - Invalid answers are re-prompted when the survey has
invalidResponseCard.enabled, capped bymaxAttempts(0means 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.
| Limit | Consequence |
|---|---|
Channel is hardcoded to email | SMS campaigns report zero messages |
Novu’s templateId filter is unreliable, so Hive re-filters client-side on templateIdentifier | Results are correct, but more pages are fetched than necessary |
| Hard stop at 50 pages of 100 | Campaigns 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 Novu | Only 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
| Variable | Required | Purpose |
|---|---|---|
NOVU_API_KEY | for any Novu feature | Sent as Authorization: ApiKey <key> |
NOVU_API_URL | recommended | Base 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—ZIntegrationNovuconfig schema.hivecfm-core/packages/types/campaign.ts—ZCampaignNovuStats,ZCampaignNovuMessage.