Follow the conversation
The events your page gets during a conversation, from its start to its end: what was said, when a reply ends, tool calls and errors.
The persona sends your page events as things happen in the conversation. Each one is a small JSON object with a type. For example, you get the persona's words as it says them:
{ "type": "session.output_transcript.delta", "event_id": "evt_88", "delta": " It's light rain" }With the JavaScript SDK, you get each event in conversation.onInterfaceEvent. In a native app, Native apps shows how to receive them.
The conversation started
session.started arrives once the persona can hear the user's microphone. The user can speak from then, and your page can start sending events. Its session field describes what is running:
session.expires_atis when the conversation will end, in Unix seconds.session.delegationholds your tool settings as the conversation uses them.session.runtime_toolslists the persona's own tools as the conversation uses them.
It doesn't include your prompt or your tools' full definitions, so keep your own copy of what you put in the token.
Words
session.input_transcript.delta gives you the user's words and session.output_transcript.delta the persona's, a few at a time as they're spoken. Join the delta values in order; they include their own spaces.
When the persona starts answering, session.input_transcript.done gives you the full text of what the user just said. Keep this one, not the pieces, as the record of what the user said. Sometimes a corrected version of the same turn follows. It has a replaces_event_id with the earlier event's id, so replace the old text with it.
Card numbers, security codes, one-time codes and Social Security numbers the user says aloud show up as [redacted]. If your page lets the user type, typed messages don't appear in these events, so show them on your page yourself.
A reply ended
session.output_audio.done arrives each time the persona finishes speaking a reply, with a reason:
reason | Why the reply ended |
|---|---|
completed | The persona finished what it had to say. |
interrupted | The reply was cut short: the user spoke over it, you sent session., Nuance stopped it, or the conversation closed. |
revised | Your append with while_ cut it, and the next reply continues from where it was cut. |
Wait for this event before acting on something the persona said, such as hanging up after it says goodbye. It's the only reliable sign that the persona has finished talking.
The persona called a tool
When the user asks for something that needs one of your tools, you get session.delegation.created, followed by the tool calls themselves inside response.event events. With the SDK you don't need to read these: onToolCall gives you each tool call. Native apps shows how to handle them without the SDK.
When the persona stays quiet
Sometimes the persona deliberately doesn't answer for a while, because it chose to with its stay_quiet tool or because your page asked it to wait. You get session.quiet.started when the silence starts and session.quiet.ended when it ends.
Errors and notices
An error event means something you sent was refused, or the conversation hit a problem.
{ "type": "error", "event_id": "evt_90", "error": { "type": "invalid_request_error", "code": "command_refused", "message": "the agent is not talking", "client_event_id": "stop_1" } }error.type is invalid_request_error, or server_error when the problem is on Nuance's side. Use error.code to tell errors apart in your code, not the message, which can change. error.param names the field at fault, and error.client_event_id the event_id of the event it answers. Most errors leave the conversation running; Errors lists the codes and the few that end it.
An info event is a notice, not an error, with a code and a message. One is delegation_cancelled: the persona started on a request for your tools but dropped it before calling any.
The conversation ended
session.closed is the last event. Its reason says why.
reason | Why |
|---|---|
close_requested | You sent session.. |
expired | The time limit ran out, at session.. |
content | A safety check ended it for a policy violation, including the user saying a Social Security number. See Safety. |
age_check | The camera showed only people who look under 18. See Safety. |
end_call | The persona ended the call after its goodbye, with its end_ tool. |
error | The conversation failed; start a new one with a new token. For now, one your server ended with the end route can also close with error, so check that first. |
connection_lost | The connection ended without a session.. |
A content or age_check end also includes a message, the exact words to show your user.
A native app also gets ended on its events request, normally just after session.closed. When the call's connection is stuck, ended is the only one that arrives. Either way, hang up. The SDK does this for you and reports session-ended.
Every event you can get
| Event | When it arrives |
|---|---|
session.started | The conversation is live and the persona hears the user's microphone. |
session.input_transcript.delta | The user's words, in pieces, as they are heard. |
session.input_transcript.done | The full text of what the user said in one turn. |
session.output_transcript.delta | The persona's words, in pieces, as it says them. |
session.output_audio.done | The audio of the persona's reply has finished playing. |
session.delegation.created | The persona took on a request for your tools or your page. |
response.event | One event about a tool request, such as a call to run. |
session., session. | The persona started or stopped staying quiet. |
session., session., session. | Your append was applied. |
session., session. | Your mute or unmute was applied. |
session.updated | Your session. was applied. |
session.usage.updated | The total seconds used so far, every 15 seconds. |
error | Something you sent was refused, or the conversation hit a problem. |
info | A notice, such as a tool request the persona dropped. |
session.closed | The conversation is over, with its reason. |