Feedback Actions
Update From Voice Feedback Action
Explains the Voice feedback action that runs during and after a live AI voice call. Useful for handling requests from the voice assistant, keeping the conversation history, and wrapping up when the call ends.
Overview
A live voice call is started with the Start Voice Chat task. While the call runs, and once when it ends, the _update_from_voice feedback action is triggered on the stub.
stubpost.data._incoming_voice_data.event tells you why the action ran:
Each update only carries what was said since the previous update. A sentence that was still being said when an update was sent continues in the next one.
The transcript since the previous update is set to the message of the stubpost, i.e. stubpost.message, as lines like:
For session_ended, the message starts with a Voice session ended: <reason> line.
All the details are available in the stubpost.data._incoming_voice_data data path.
A delegation doesn't say what the assistant needs. Work it out from the messages, eg by running a GPT Chat Task with them.
Handling the events
delegation
- Run a GPT Chat Task with the
messages. - When its answer arrives, send it to the call with a
commentaryvoice notification and thedelegation_id:
While it waits, the assistant tells the caller it is checking.
interval
Store the messages in the chat history, so the agent has the whole conversation the next time it runs.
session_ended
Wrap up, eg save a summary of the call or send a follow-up. session_ended.reason tells you how the call ended.
The charge for the length of the call comes with this update, and is added to the stubpost's transaction history like the charges of tasks.
Data Structure
Feedback Action Data
Example data that is passed to the _update_from_voice feedback action for a delegation:
When the call has ended:
Properties
event string
Why the action ran: delegation, interval or session_ended.
delegated boolean
true when the assistant needs the stub's help, i.e. when event is delegation.
voice_session_uuid string
The id of the voice call, from Start Voice Chat.
chat_name string
The chat_name the call was started with.
channel string
The channel of the call, eg webchat.
messages array
What was said since the previous update, as chat messages. The caller is user and the assistant is assistant. This is the same format as the GPT Chat Task messages.
Empty when nothing new was said, eg for a session_ended straight after a delegation.
transcript array
The timed fragments behind the messages. Each fragment has a speaker (caller or assistant), the delta text, and start_ms and end_ms, the time in milliseconds from the start of the call.
delegation_id string
delegation only. Pass it back with the answer, so the assistant knows which request it answers.
offset_ms number
delegation only. When the assistant delegated, in milliseconds from the start of the call.
session_ended.status string
session_ended only. closed, or abandoned when the caller's channel never joined the call.
session_ended.reason string
session_ended only. How the call ended:
session_ended.usage_seconds number
session_ended only. The billed length of the call in seconds. Time before the caller joined isn't billed.
session_ended.usage_confirmed boolean
session_ended only. true when the AI provider confirmed the final usage_seconds. When false, usage_seconds is the last known value.
JSONSchema
The JSONSchema of the stubpost.data._incoming_voice_data is: