Chat

A real-time messaging interface that supports sending and receiving messages over MeshSocket. Ideal for device-to-device communication, command logs, or interactive chatbots.

Type

"chat"

Relevant Fields

Inherits all Control Definition. Key fields:

Field Type Default Description
label string falls back to id Header label
config.target string MeshSocket peer name to route messages to. Set this for companion/bot chat; omit for channel chat
config.showTypingIndicators bool true Show typing bubbles
config.showReadReceipts bool true Show read receipts
config.allowReactions bool true Allow emoji reactions on messages
config.allowReplies bool true Allow threaded replies
config.allowImages bool false Allow image attachments
config.historyCount number 50 Number of messages to keep in history
config.tint string "#667eea" Chat bubble accent color

Examples

Device-to-device chat

{
  "type": "chat",
  "id": "team-chat",
  "position": [0, 0],
  "span": [4, 4],
  "label": "Team Chat",
  "config": {
    "target": "hub-server",
    "showTypingIndicators": true,
    "showReadReceipts": true,
    "allowReactions": true,
    "allowReplies": true,
    "historyCount": 100
  }
}

Wire Protocol

When config.target is set, the chat routes to that peer by name (companion mode):

Outgoing — every message you send:

"route_msg_noreply": {
  "target_name": "companion",
  "type": "chat_message",
  "payload": { "text": "your message" }
}

Incoming — the companion replies with a broadcast the chat listens for:

"broadcast": { "event": "chat_response", "text": "the reply" }

The optional name / sender.name / from field on the broadcast sets the reply's display name; otherwise it falls back to the target name.

The companion (server side) must wait for the MeshSocket welcome before routing — connect, wait_until_ready(), then wait for the welcome event before sending.

Without config.target (channel mode) the chat sends a chat_message event and listens on chat_message for the whole channel.