Developer integration guide
This guide maps common integration patterns to DNotifier capabilities — for frontend-only, backend-only, and full-stack teams. It replaces ad-hoc "how do I wire this?" questions with concrete architectures using realtime 1:1 messaging, chat, AI, and workflows.
Before you integrate
2
Create an app and note App ID + secret
3
Install SDK — npm or pub.dev
4
Choose transport — WebSocket for live client; HTTP for AI/RAG and server send
User ID scheme: Decide early how IDs map to auth users, devices, bots, and service accounts. IDs are routing keys for all messaging.
Capability quick reference
Realtime communication
Live delivery to known IDs
connect, send, sendBinary, HTTP RPC send
Chat
Threads with history
send + fetchChatHistory, deleteChatHistoryMessage
AI
LLM + RAG
sendAI, addDocument, search
Workflows
Multi-step agents
defineAgent, Workflow, run workflow
Frontend integration patterns
Frontend apps (React, Vue, Svelte, Flutter, etc.) typically hold a WebSocket connection for realtime and call HTTP transport for AI where appropriate.
Connect on login
Realtime dashboards via 1:1 messaging
Goal: Admin dashboard updates live when metrics change.
Client
Connect as userId: adminUser.id (or per-dashboard session ID)
Backend
Metric job sends { type: "metrics", data } to that receiverId
UI
onMessage updates charts
No shared channel — each dashboard session is an ID you control.
In-app notifications
Goal: Toast or inbox when events occur.
User connects with authenticated
userId.Backend event → server send to
receiverId: userId.Payload
{ type: "notification", title, body, link }.Client routes by
typeinhandleIncoming.
Works for order updates, mentions, approvals, and system alerts.
Collaborative UI sync
Goal: Two or more users see cursors, selections, or document ops.
Peer sync
User A sends ops to User B's ID
Fan-out
Your app maintains participant array; loop receiverIds
Authority
Backend merges; pushes canonical state to each participant ID
DNotifier delivers ops; conflict resolution stays in your app.
Embedded chat UI
Goal: 1:1 or support chat in your product.
Connect WebSocket on thread open.
fetchChatHistoryfor sender + peer IDs.sendwithsaveHistory: true.Render with Chat UI patterns.
Bot participants use the same APIs with a bot userId.
Live progress tracking
Goal: Progress bar for upload, export, or AI job.
Client connects before starting job.
Worker sends
{ type: "progress", percent, label }to user's ID.UI updates from
onMessage; show complete state at 100%.
Pair with workflows for multi-step AI pipelines.
AI panels (frontend)
For copilots and assistants in the UI:
Use HTTP transport for predictable request/response. Optionally push long-running results via WebSocket when done.
→ Send a prompt
Backend integration patterns
Backend services (Node, Dart server, etc.) connect for server-side send, AI/RAG, and workflow execution — often without a persistent WebSocket.
Server-side message delivery (HTTP RPC send)
Goal: Push events to online users from cron jobs, microservices, or webhooks.
1
User already connected on frontend with known userId
2
Backend uses SDK or HTTP API with app credentials
3
Send payload with receiverId: targetUserId
4
Client receives in onMessage
This is backend-to-client updates — the standard pattern for notifying a specific user without polling.
Webhooks to realtime bridge
Goal: External systems (payment processors, CI/CD webhooks, internal ERP) trigger live client updates.
Receive
POST webhook to your endpoint
Verify
Signature / secret validation
Resolve user
Map event to DNotifier userId (e.g. customer ID)
Deliver
Send structured payload to that ID
Optional
Persist event in your DB before send
Example payloads:
{ type: "payment-succeeded", invoiceId }{ type: "deploy-complete", environment }
The bridge is your code — DNotifier is the last mile to connected clients.
Microservice events via direct messaging to user IDs
Goal: Service A notifies Service B or an end user without a separate client-facing bus.
User last mile
Billing service sends to user-123 — mobile app shows alert
Service to service
svc-inventory sends to connected svc-orders worker ID
Job completion
Worker sends result to requesting user's ID
Assign service account IDs the same way as user IDs — any connected client with that ID receives messages.
AI and RAG on the server
Goal: Keep prompts and document ingestion on trusted infrastructure.
Run workflows on the server for batch processing, cron-driven reports, and webhook-triggered AI.
Workflow runner (backend)
Define agents and workflows in code; execute from API routes or workers:
Register agents with
DNotifier.defineAgent.Build
WorkflowwithentryandregisterAgents.On request, instantiate
DNotifier(HTTP), connect, run workflow with input.Return result to HTTP client or push to user via
sendif they wait on WebSocket.
Enable observability: true for production debugging.
→ Run a workflow
Full-stack integration patterns
Full-stack teams split connection ownership (client WebSocket) and authority (server AI, routing, webhooks).
Recommended split
User chat UI
Frontend
WebSocket
Live notifications
Backend → client
HTTP send or WS
AI / RAG / workflows
Backend
HTTP
Auth / secrets
Backend
—
User ID issuance
Backend
—
End-to-end: support chat with AI handoff
Frontend
Widget: WS connect, chat UI, onMessage
Backend API
Route messages; run workflow; assign agents
AI
sendAI + RAG for bot; workflow for escalation
Realtime
Status events to user ID (agent-joined, queue)
Chat
History between user, bot, and agent IDs
End-to-end: export with live progress
Frontend
Start export; WS connected
Backend
Queue job with userId metadata
Worker
Progress + complete messages to that ID
Optional AI
Workflow summarizes export contents
End-to-end: collaborative document
Frontend
WS; send ops to peer IDs
Backend
Persist snapshots; optional merge authority
Realtime
Op delivery only
Optional AI
Side panel sendAI over HTTP
Transport decision matrix
Chat UI
WebSocket
HTTP send for push
AI assistant panel
HTTP (or WS if unified)
HTTP
Dashboard live metrics
WebSocket
HTTP send
Webhook → user alert
—
HTTP send
Workflow batch job
—
HTTP
Full matrix: Transport method matrix
Multi-platform clients
Use the same app credentials; align userId with your auth across web and mobile.
Production checklist (integration-focused)
Secrets only on server
No app secret in mobile/web bundles
Stable user IDs
Same auth user → same DNotifier ID
Reconnection
Plan limits
getPlanLimits() gates features
Logging
logs: true for AI; workflow observability in prod
Payload schema
Versioned type field in JSON messages
Where to go next
Use case deep dives
API reference
Copy-paste examples
Troubleshooting
Support links
Last updated