Skip to content

Omnichannel Notifications (dxosNotify) ​

The notification subsystem in @latticedx/plugin-lattice-foundation separates internal portal bell alerts (notification-center.js, stored in latticeNotifications) from outbound omnichannel delivery (omnichannel-notify.js, exposed via dxosNotify and logged in latticeNotificationDeliveries). All channel credentials remain encrypted inside latticeConnectors (AES-256-GCM via dxosVault) and are never exposed in API responses or delivery logs.

Supported Channels and Routing Architecture ​

dxosNotify routes outbound messages across four external transports (SUPPORTED_CHANNELS: smtp, telegram, slack, webhook), alongside internal in_app notifications and optional DX_APPRISE_URL / DX_NOTIFICATION_WEBHOOK_URL bridges. Direct CRUD requests against latticeNotificationDeliveries are blocked by middleware; all sends and log reads must invoke dxosNotify.

ChannelBacking dxosVault ConnectorPayload FormatChannel-Specific Input Guards
smtpemail_smtpInterpolated plain text or HTML body via {{var}}Rejects \r, \n, \0 to block header injection (SMTP_HEADER_INJECTION_BLOCKED).
telegramtelegramText message dispatched via Bot APIValidates bot token format ([0-9]{5,16}:[A-Za-z0-9_-]{20,120}) and chat_id.
slackslackIncoming Webhook or Web API JSONClassifies transient ratelimited, internal_error, and fatal_error replies.
webhookwebhook / HTTP connectorCustom JSON template or default lattice.notification envelopeEnforces asynchronous DNS SSRF checks (assertSafeConnectorUrlAsync).
in_appInternal notification centerRow in latticeNotifications scoped by user or roleRead and acknowledged via the latticeNotifications resource.
POST/api/dxosNotify:send
Bearer JWT | ldx_pat_*write
Dispatches notifications to a single channel or fans out across multiple channels (requires operator or admin role).
Request Parameters for dxosNotify:send
ParameterTypeDefaultDescription
channel / channelsrequired
string | string[]—Single channel name or array from [smtp, telegram, slack, webhook].
connectorKey
string—Specific connector key in dxosVault; defaults to the active connector for that channel.
target
string | string[]—Recipient target (email addresses, Telegram chat_id, or permitted override).
titlerequired
string—Notification title supporting {{var}} template placeholders.
bodyrequired
string—Notification body supporting {{dot.path}} lookup and optional HTML escaping.
variables
object—Context object passed to renderTemplate and renderWebhookPayload.
template
object | string—Structured JSON template used for webhook or Slack payloads.
dryRun
booleanfalseRenders payloads and validates routing without executing network requests.

Template Interpolation and Secret Scrubbing ​

renderTemplate(template, vars, { htmlEscape }) resolves {{dot.path}} placeholders using Object.hasOwn traversal while blocking prototype pollution keys in BLOCKED_PATH_KEYS (__proto__, constructor, prototype). When htmlEscape: true is active for HTML email bodies, &, <, >, ", and ' characters are escaped.

For webhook targets, renderWebhookPayload recursively interpolates template strings (sanitizeAndInterpolateNode) or constructs a structured default JSON envelope when no custom template is supplied:

json
{
  "event": "lot.held_mkt",
  "organizationId": "org-coldchain-01",
  "category": "cold_chain",
  "severity": "high",
  "title": "MKT threshold exceeded on lot LOT-2026-A09",
  "body": "Computed MKT 8.74C exceeded threshold 8.0C",
  "targetCollection": "latticeStockLots",
  "targetRecordId": 41,
  "targetPath": "/p/incidents",
  "timestamp": "2026-11-26T16:10:00.000Z"
}

Before persisting delivery attempts into latticeNotificationDeliveries, the engine applies two sanitization layers (maskTarget and scrubSecrets):

Sanitization FunctionInspected FieldPersisted Output in latticeNotificationDeliveries
maskEmail (smtp)Recipient email addressesPreserves first character and domain (a***@example.com).
maskTarget (telegram)Telegram chat_idPreserves first 2 and last 2 characters (12***89).
scrubSecretsError strings, headers, and response payloadsReplaces Telegram bot tokens, Bearer/Basic headers, Slack xox* tokens, and Vault secrets with [REDACTED].

Retry Policy and Exponential Backoff ​

Outbound transport calls apply DEFAULT_TIMEOUT_MS = 6000 ms and up to DEFAULT_MAX_ATTEMPTS = 3 attempts (configurable from 1 to 5). Retries trigger strictly on transient errors marked err.retryable === true, failing immediately on permanent validation or authorization errors.

Transport / ChannelRetryable Conditions (retryable = true)Immediate Failure Conditions (retryable = false)
HTTP (webhook, telegram)HTTP 429, HTTP >= 500, network resets, or 6000 ms timeout.HTTP 400, 401, 403, 404, or SSRF-blocked destinations.
SMTP (smtp)Transient 4xx SMTP replies or TCP/TLS connection errors.Permanent 5xx SMTP errors, invalid address, or SMTP_HEADER_INJECTION_BLOCKED.
Slack (slack)ratelimited, internal_error, fatal_error, or HTTP >= 500.invalid_payload, channel_not_found, or invalid_auth.

The delay between retry attempts follows capped exponential backoff:

text
delayMs = Math.min(5000, 250 * 2 ** (attempt - 1))

With DEFAULT_BACKOFF_BASE_MS = 250 ms and MAX_BACKOFF_MS = 5000 ms, the dispatcher waits 250 ms after the first failure and 500 ms after the second failure before recording the final delivery state.

dxosNotify API Reference ​

EndpointMethodRequired RoleResponsibility
/api/dxosNotify:sendPOSTOPERATOR_ROLES (root, admin, ldx_admin, ldx_manager, operator)Sends single-channel or multi-channel notifications using org connectors.
/api/dxosNotify:testSendPOSTELEVATED_ROLES (root, admin, ldx_admin)Verifies connector reachability and template rendering against dxosVault.
/api/dxosNotify:logsGETELEVATED_ROLES (root, admin, ldx_admin)Queries latticeNotificationDeliveries with masked targets and scrubbed errors.
/api/dxosNotify:channelsGETloggedInLists supportedChannels and active organization connectors without secrets.
GET/api/dxosNotify:logs
Bearer JWT | ldx_pat_*read, write
Queries masked notification delivery logs filtered by channel, status, and dryRun.
Query Parameters for dxosNotify:logs
ParameterTypeDefaultDescription
channel
string—Filter logs by transport channel: smtp, telegram, slack, or webhook.
status
string—Filter logs by delivery outcome: sent, failed, or dry_run.
dryRun
boolean—Filter specifically for simulated dry-run dispatches.
limit
integer50Maximum number of log rows returned per request.
offset
integer0Pagination offset ordered from most recent delivery.

Environment Variables and SSRF Boundaries ​

By default, omnichannel-notify.js resolves every destination hostname asynchronously (assertSafeConnectorUrlAsync) and blocks loopback, RFC 1918 private ranges, link-local (169.254.*), and cloud metadata endpoints. Operators control internal network access through four environment settings:

Environment VariableDefaultPurpose
DX_APPRISE_URL(unset)Optional Apprise gateway URL for additional external notification providers.
DX_NOTIFICATION_WEBHOOK_URL(unset)Platform fallback webhook endpoint when no tenant connector is specified.
DX_ALLOW_INTERNAL_CONNECTORS'false'Controls whether internal network webhook destinations are permitted.
DX_INTERNAL_SERVICE_HOSTS(unset)Explicit allowlist of internal hostnames permitted when enabled by root.
bash
curl -X POST https://app.example.com/api/dxosNotify:send \
  -H "Authorization: Bearer ldx_pat_a1b2c3d4_..." \
  -H "Content-Type: application/json" \
  -d '{
    "channels": ["telegram", "slack", "webhook"],
    "title": "Cold room excursion in {{warehouseCode}}",
    "body": "Lot {{lotCode}} recorded MKT {{mktCelsius}}C",
    "variables": {
      "warehouseCode": "WH-CT-01",
      "lotCode": "LOT-2026-A09",
      "mktCelsius": 8.74
    }
  }'

In automated workflows, the notify.send LatticeFlow v2 node invokes this omnichannel dispatcher alongside in_app bell notifications, while latticeSlaPolicies and dxosApprovals route SLA escalations across configured notifyChannels.

Apache-2.0 · LatticeDX v0.4.2 · Powered by NocoBase · v2.2.50 · Apache-2.0 (Clause 5.2)