Control the Agent

Once your app is connected to the LiveKit room (see Quickstart), all commands to the agent are sent via sendText() on a data-channel topic. This guide covers the three command topics and their payload formats.

Note: If you are using the D-ID Agents SDK or Embed Code, these details are handled internally — call speak() and chat() instead.

Commands

CommandTopicPayload
speakdid.speak{ "script": { "type": "text", "input": "..." } }
chatlk.chatplain text string
interruptdid.interruptempty string

speak

Generates video from text (equivalent to the V1 Talks/Clips Streams API).

  • Topic: did.speak
  • Payload: { "script": { "type": "text", "input": "Your text here" } }
  • Use for: scripted content, announcements, predetermined messages, faster generation without LLM processing

chat

Sends a conversational message. The agent's LLM processes the input and responds.

  • Topic: lk.chat
  • Payload: plain text string
  • Use for: natural conversations, Q&A, context-aware responses using a knowledge base

interrupt

Interrupts the current video sequence and returns the agent to idle.

  • Topic: did.interrupt
  • Payload: empty string
  • Use for: stopping a long response, barge-in flows. Requires interrupt_enabled on the agent (default true).

Sending commands

   // speak — generate video from text
   await room.localParticipant.sendText(
     JSON.stringify({ script: { type: "text", input: "Hello!" } }),
     { topic: "did.speak" }
   );

   // chat — conversational message
   await room.localParticipant.sendText(
     "What is the weather?",
     { topic: "lk.chat" }
   );

   // interrupt — stop the current video
   await room.localParticipant.sendText("", { topic: "did.interrupt" });