1. Template Guidelines
  2. Voice

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_chat task, which returns a sessionuuid.
  • The task passes in a greeting instruction, the voice prompt, 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_voice is triggered at that interval with a transcript delta. Use it to update the conversational agent's chat history. Only the messages are updated, so submit_to_model is not needed.
  • _update_from_voice is also triggered immediately when the voice agent delegates to the conversational agent. Submit this to the conversational agent with submit_to_model set to true, 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 the voice platform to pass its message to the voice agent.
  • The voice agent then speaks to the user, following the voice prompt.
  • 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.voice on the template data.
  • Save the greeting prompt for a new voice call in prompts.voice_greeting on 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.