Template Guidelines
Voice
Explains how live voice is layered on top of a conversational agent by delegating to the main chat.
Stubber supports live, synchronous voice as a layer on top of the conversational agent defined in your flow. A voice agent talks to the user and delegates instructions to the underlying conversational agent in the main chat. This lets flows built for text chat work with live voice without being rebuilt. See Live Voice for the concept.
Voice channels
Voice can work alongside these channels:
- webchat: an optional voice channel from the webchat component on a website
- hosted webchat: the full-page chat interface built into Stubber
- WhatsApp: direct voice through the WhatsApp API (see WhatsApp calling)
voicecall: the SIP protocol, to integrate with existing voice systems
Each channel's documentation explains how to enable voice alongside it.
Enabling voice
To enable voice on a channel, consider two things:
- the architecture: where the voice call is started and how it is routed to a conversation stub
- the flow components: what you add to the template to set up the delegated voice model, and how it interacts once the call is live
Flow setup
- Start a voice agent with the
start_voice_chattask, which returns asessionuuid. - The task passes in a greeting instruction, the
voiceprompt, and model parameters such as the voice type and sound formats. - The task also sets the interval at which transcript updates are sent back to the stub.
- While the call is in progress,
_update_from_voiceis triggered at that interval with a transcript delta. Use it to update the conversational agent's chat history. Only the messages are updated, sosubmit_to_modelis not needed. _update_from_voiceis also triggered immediately when the voice agent delegates to the conversational agent. Submit this to the conversational agent withsubmit_to_modelset totrue, so the LLM handles the conversation up to that point.- The earlier chat messages are already present, so only the delta passed with the latest delegation needs to be appended.
- When the conversational agent responds through
_update_from_chat_assistant_task, send a notification on thevoiceplatform to pass its message to the voice agent. - The voice agent then speaks to the user, following the
voiceprompt. - On key actions in the flow, you can add a task that updates the voice agent with new instructions or commentary. These can be short commentary updates, similar to webchat status messages, or explicit new instructions when the flow changes state.
Standards
- Save the prompt that instructs the voice agent in
prompts.voiceon the template data. - Save the greeting prompt for a new voice call in
prompts.voice_greetingon the template data.
Dual channel
When a voice agent is started from webchat or WhatsApp, the user has a second channel: the voice agent can ask them to send information as text, or to send an image or file.
Supporting this means deciding how the chat channel's feedback action interacts with the conversational agent. There are two options:
- pass the message from the chat feedback action directly to the conversational agent, or
- send the message to the voice agent as a commentary update, and let the voice agent delegate to the conversational agent.