Voice Agent Message Flow
Implement the correct WebSocket message sequence for Voice Agent conversations.
This guide walks you through implementing the correct message flow when building a Voice Agent client. Follow these steps to establish a connection, configure settings, and handle the conversation loop.
Open a WebSocket connection to the Voice Agent endpoint.
Wait for the server to send a Welcome message confirming the connection:
Do not send any messages until you receive the Welcome message.
Settings message with your audio and agent configuration:SettingsApplied message:Do not send audio or inject messages until you receive SettingsApplied.
After receiving SettingsApplied, begin streaming binary audio data (PCM) continuously to the server.
Optionally, send text input using InjectUserMessage:
Confirm your implementation works correctly by checking:
Welcome message immediately after connecting.SettingsApplied message after sending your Settings.ConversationText and binary audio when you speak or inject text.UserStartedSpeaking (barge-in detection).