Deploy Your OmniagentMessaging

Client Commands

Send messages and update session settings from your client during a session

Your client sends commands to the server during an active WebRTC or WebSocket session: send_message to send information to the agent, set_settings to update session configuration on the fly, send_mcp_approval to answer an MCP tool approval, and talk to make the agent speak a line in puppeteer mode.

Sending commands

WebRTC (Web SDK)

Call sendCommand on the SDK instance. The Web SDK also ships typed command definitions and usage patterns for this — see Web SDK → Messaging.

instance.sendCommand({
  type: "send_message",
  data: {
    role: "user",
    text: "Hello",
    trigger_response: true,
    delay: false
  }
});

WebSocket

Send the command as JSON over the WebSocket connection:

ws.send(JSON.stringify({
  type: "send_message",
  data: {
    role: "user",
    text: "Hello",
    trigger_response: true,
    delay: false
  }
}));

send_message

Send text to the agent as a user message or a system context update.

{
  "type": "send_message",
  "data": {
    "role": "user",
    "text": "What is the status of my order?",
    "trigger_response": true,
    "delay": false
  }
}

Parameters

ParameterTypeRequiredDescription
roleuser or systemYesWho the message is from
textstringYesThe message content
trigger_responsebooleanYesWhen true, the agent responds immediately. When false, the agent absorbs the information silently and may or may not act on it based on conversation context
delaybooleanNoWhen true, waits for the agent to finish speaking before delivering the message and triggering a response. When false, delivers immediately — interrupting the agent if it is speaking. Default: false

User messages

When role is user, the agent treats the text as if the user typed it instead of speaking. This is useful for text-based input alongside audio, or for injecting user intent programmatically.

{
  "type": "send_message",
  "data": {
    "role": "user",
    "text": "Tell me more about the premium plan",
    "trigger_response": true
  }
}

System messages

When role is system, the text is treated as a context update. The agent incorporates the information into its context without displaying it to the user. Use this when something changes in your application that the agent needs to know about.

{
  "type": "send_message",
  "data": {
    "role": "system",
    "text": "The user just added 'Wireless Headphones' to their shopping cart.",
    "trigger_response": false
  }
}

Triggering a response

When trigger_response is true, the agent generates a response immediately. When false, the agent absorbs the information silently — it does not respond right away, but may incorporate it into future replies based on the conversation context.

The delay parameter controls when the message is delivered. When delay is false (the default), the message is delivered immediately, interrupting the agent if it is currently speaking. When delay is true, the message is held until the agent finishes its current speech, then delivered — and if trigger_response is true, the agent responds after that.

{
  "type": "send_message",
  "data": {
    "role": "system",
    "text": "The user's subscription has been upgraded to premium.",
    "trigger_response": true,
    "delay": true
  }
}

set_settings

Update session parameters in real time without creating a new connection. Change the agent's instructions, temperature, turn detection, modality, or tools, or refresh MCP tokens.

{
  "type": "set_settings",
  "data": {
    "instructions": "You are a customer support agent. Be concise and helpful.",
    "temperature": 0.7,
    "turn_detection": {
      "threshold": 0.5,
      "prefix_padding_ms": 300,
      "silence_duration_ms": 500
    }
  }
}

All fields are optional. Include only the settings you want to change — omitted fields keep their current values.

Parameters

ParameterTypeArchitectureDescription
instructionsstringRealtime, CascadeReplace the agent's system instructions
temperaturenumberRealtimeSet the response temperature (0-1)
turn_detectionobjectRealtimeConfigure voice activity detection
modalitystringRealtimeSwitch between audio and text mid-session. Switching to audio fails if the session has no voice
inline_functionsarrayRealtime, CascadeRegister tools for the rest of the session. Replaces any tools registered this way earlier. See the example under Common patterns
mcp.authorizationsarrayRealtimeReplace the tokens for per-user MCP servers. Each item is { "mcp_server_id", "token" }. See Refreshing a token mid-session.

set_settings isn't supported on Microsoft Foundry.

turn_detection

ParameterTypeDescription
thresholdnumberSensitivity threshold for detecting speech
prefix_padding_msnumberMilliseconds of audio to include before detected speech
silence_duration_msnumberMilliseconds of silence before a turn is considered complete

Common patterns

Replacing instructions mid-conversation — instructions fully replaces the agent's system prompt. Use this when the agent's entire role or behavior needs to change, for example when the user moves to a different part of your application:

{
  "type": "set_settings",
  "data": {
    "instructions": "You are a checkout assistant for an e-commerce store. Guide the user through completing their purchase. Confirm the shipping address, suggest available shipping options, and answer questions about return policies. Do not suggest additional products."
  }
}

This replaces the full system prompt — it is not appended to the existing instructions. If you want to provide a contextual update without changing the agent's instructions, use send_message with role: system instead.

Providing context updates — use send_message with role: system to give the agent situational context without replacing its instructions. For example, notify the agent when the user navigates to a different page:

{
  "type": "send_message",
  "data": {
    "role": "system",
    "text": "The user just navigated to the checkout page.",
    "trigger_response": false
  }
}

Registering tools mid-session — add tools the agent can call for the rest of the session, without creating them with the API first. Each item uses the same shape as a tool definition:

{
  "type": "set_settings",
  "data": {
    "inline_functions": [
      {
        "id": "get_cart",
        "flow": "implicit",
        "data": {
          "name": "get_cart",
          "description": "Get the items currently in the user's shopping cart.",
          "parameters": { "type": "object", "properties": {} }
        }
      }
    ]
  }
}

Only implicit tools, and explicit tools served over an http or https URL, can be registered this way. Names must be unique and can't collide with the agent's own tools. Each set_settings with inline_functions replaces the tools registered this way before.

Refreshing an MCP token — when a per-user MCP server's access token is about to expire, send the fresh token. The list replaces all tokens, so include every server that needs one:

{
  "type": "set_settings",
  "data": {
    "mcp": {
      "authorizations": [
        {
          "mcp_server_id": "crm",
          "token": "ya29.a0AfH6_refreshed..."
        }
      ]
    }
  }
}

Adjusting turn detection for noisy environments — increase silence_duration_ms so the agent waits longer before treating silence as the end of the user's turn:

{
  "type": "set_settings",
  "data": {
    "turn_detection": {
      "silence_duration_ms": 1000
    }
  }
}

send_mcp_approval

Answer a pending mcp_approval_request. Only relevant when an attached MCP server is registered with requireApproval: "always".

{
  "type": "send_mcp_approval",
  "data": {
    "approval_request_id": "mcpr_x9y8z7",
    "approve": true
  }
}

Parameters

ParameterTypeRequiredDescription
approval_request_idstringYesThe item_id from the mcp_approval_request event
approvebooleanYestrue runs the tool call; false cancels it and the MCP server is never contacted
reasonstringNoFree text explaining the decision, passed upstream with it

Send exactly one decision per request — later or duplicate decisions for the same approval_request_id are ignored. If nothing arrives within 15 seconds, the request is rejected automatically and you receive a cancelled event.

The Web SDK does not yet include send_mcp_approval in its typed command definitions. In TypeScript you will need to cast the command until a typed method ships.

talk

In puppeteer mode, send talk to make the agent speak a line of text exactly as written.

{
  "type": "talk",
  "data": {
    "talkId": "intro-1",
    "text": "Welcome to Acme. Let me show you around the new dashboard."
  }
}

Parameters

ParameterTypeRequiredDescription
talkIdstringYesYour ID for this line. It comes back as talk_id on talk_state_changed events, so you can tell when the line starts and finishes.
textstringYesThe text for the avatar to speak.
splitbooleanNoSpeak the text sentence by sentence. Defaults to true.

Track each line with talk_state_changed: preparing, then started and ended. If the user starts speaking while the agent is talking, the current line stops and you receive canceled.


Next steps

On this page