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

Your first message

After a successful connection, you can send a 1:1 realtime message to another user. This hub explains the concept; language pages have runnable code.

What you are building

A minimal flow with two logical users:

  user-alice (your SDK)                    user-bob (another client)
         β”‚                                          β”‚
         β”‚  send({ receiverId: "user-bob", ... })   β”‚
         β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Ίβ”‚
         β”‚                                          β”‚
         │◄──────────────────────────────────────────
         β”‚         onMessage on bob's client          β”‚

Both users connect with the same appId but different userId values. Messages route by senderId and receiverId.

Requirements

  • transport: "ws" β€” realtime send/receive uses WebSocket

  • connect() completed β€” isConnected === true

  • Receiver exists conceptually β€” the receiver does not need to be online; DNotifier delivers when they connect (subject to plan and app rules)

The send() call

All SDKs expose a similar send() shape:

Field
Description

senderId

Must match the connecting user's id (your userId)

receiverId

Target user's id (single recipient)

data

JSON-serializable payload β€” typically { type: "text", text: "..." }

saveHistory

Optional; default true β€” persist for chat history APIs

Example payload:

Use any type string your app understands (text, image, audio, doc, custom types).

Receiving messages

Incoming messages arrive on the onMessage callback registered at construction time. Each message has:

  • metadata β€” sender, timestamp, id, type

  • payload β€” body with helpers like toJSON()

See Understanding messages for the full model.

Language guides

Language
Guide

JavaScript / TypeScript

Dart / Flutter

Python

Test with two clients

To see end-to-end delivery:

  1. Run two terminal processes (or two browser tabs)

  2. Connect as user-alice in one and user-bob in the other

  3. Send from alice to bob and watch bob's onMessage fire

Next steps

Last updated