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

Choose your transport

DNotifier SDKs support two transports: WebSocket (ws) and HTTP (http). Both use the same credentials and authenticate the same way at connect(). The difference is how messages flow after authentication.

Decision table

Criterion

WebSocket (ws)

HTTP (http)

Best for

Realtime messaging, live chat, push-style delivery

AI prompts, RAG, knowledge-base APIs, workflows

Connection

Persistent socket; server pushes incoming messages

Stateless request/response per call

Incoming messages

Delivered to onMessage in real time

Not used for push; responses return from method calls

send() for 1:1 chat

βœ… Recommended

⚠️ Possible but not ideal for live UX

sendAI()

❌ Use HTTP instead

βœ… Recommended

Knowledge base (add/search/list)

❌ Use HTTP instead

βœ… Recommended

runWorkflow()

❌ Use HTTP instead

βœ… Recommended

Browser support

Native WebSocket API

fetch / standard HTTP

Node.js

Requires WebSocketImpl (e.g. ws package)

Works out of the box

Reconnect handling

Your app should handle disconnects

N/A β€” each call is independent

When to use WebSocket

Choose transport: "ws" when you need:

  • Realtime 1:1 messaging between users, devices, or services

  • Live chat with instant delivery to onMessage

  • Binary or large structured payloads with automatic chunking over a persistent connection

  • Low-latency push without polling

Typical apps: chat clients, live collaboration, device telemetry with bidirectional frames, notification feeds where the server initiates delivery.

When to use HTTP

Choose transport: "http" when you need:

  • AI β€” sendAI, session continuation, fetchAIHistory

  • RAG / knowledge base β€” addDocument, search, listDocuments, etc.

  • Workflows β€” runWorkflow with agents and observability

  • Server-side RPC where each operation is a discrete HTTP call

Typical apps: backend AI assistants, document indexing pipelines, admin tools, cron jobs, API routes that answer a prompt and return JSON.

Can I use both?

Yes. Many production systems use two SDK instances (or reconnect with different transports at different lifecycle stages):

Component
Transport
Role

Chat UI

ws

Realtime send/receive

API server

http

AI, RAG, workflows

Use the same appId and secret, but pick the transport that matches each code path.

Authentication is the same

Both transports call the DNotifier auth endpoint during connect(). You receive:

  • An auth token

  • Plan limits (getPlanLimits())

  • aiEnabled and message size caps

WebSocket clients then open a socket and complete a handshake. HTTP clients mark themselves connected without maintaining a socket.

Next steps

Last updated