Events
The events array in an Exchange records session activity, tool calls and results, transfers, and errors. Each event has a timestamp and type-specific data.
Event structure
Each event object includes:
| Field | Type | Description |
|---|---|---|
type | string | The event type identifier |
time | string | ISO 8601 timestamp of when the event occurred |
data | object | Type-specific event data |
Common event types
| Event Type | Description |
|---|---|
session_start | Marks the beginning of the conversation session |
tool_call | Records when the Assistant invokes a tool |
tool_result | Records the result returned by a tool |
session_end | Marks the end of the conversation with summary statistics |
startup_request | Records a configured startup HTTP request and its outcome |
assistant_transfer | Records a successful transfer to another Assistant |
assistant_transfer_failed | Records a failed Assistant transfer |
amd_result | Records the answering machine detection result when it runs |
Other events can describe user inactivity, session errors, or audio decoding errors.
Note
The examples record a technical support call in which the Assistant checked system status. See Messages for the transcript.
session_start
Recorded when the conversation session starts. Its data object is empty.
Example
Code
tool_call
Recorded when the Assistant invokes a tool during the conversation. This event captures the tool name, the arguments passed to it, and whether it's an MCP tool.
For MCP tools, the SDK reports the call and result after execution. Their timestamps can therefore reflect when the execution was recorded rather than its actual start time.
Data fields
| Field | Type | Description |
|---|---|---|
toolName | string | Name of the tool being called |
arguments | object or string | Arguments passed to the tool; encoding depends on the tool |
isMcpTool | boolean | Whether this tool is provided via Model Context Protocol (MCP) |
Example
Code
tool_result
Recorded immediately after a tool call completes. This event captures the tool's response and whether an error occurred.
Data fields
| Field | Type | Description |
|---|---|---|
toolName | string | Name of the tool that was called |
result | any | Tool response; it may be structured data or a string |
hasError | boolean | Whether the tool execution resulted in an error |
isMcpTool | boolean | Whether this tool is provided via Model Context Protocol (MCP) |
Example
Code
session_end
Recorded after post-processing at the end of the conversation. Contains summary statistics for the call.
Data fields
| Field | Type | Description |
|---|---|---|
durationSeconds | number | Total duration of the conversation in seconds |
messageCount | object | Message counts by sender |
messageCount.user | number | Number of messages from the user |
messageCount.assistant | number | Number of messages from the Assistant |
messageCount.total | number | Total number of messages |
eventCount | number | Total number of events during the session (excluding session_end) |
audioUrl | string or null | URL to the conversation audio recording (for voice conversations) |
Example
Code
Complete example: technical support conversation
This events array records the session start, a system-status tool call and its result, and the session end.
Code
Event timeline
| Time | Event | Description |
|---|---|---|
| 16:04:46 | session_start | User connects to the Technical Support Assistant via WebRTC |
| 16:05:29 | tool_call | Assistant invokes getSystemStatus to check for outages |
| 16:05:29 | tool_result | Tool returns "System status: OK" |
| 16:05:54 | session_end | Conversation ends after 68 seconds with 8 total messages |
Usage notes
- Events are ordered chronologically by their
timefield - A normally completed session includes
session_startandsession_end - Tool executions normally produce a
tool_callfollowed by atool_result; an interrupted execution may leave an unmatched call - The
eventCountinsession_endcounts events that occurred during the session (not includingsession_enditself) - Timestamps use ISO 8601 and may include fractional seconds
session_end.data.messageCountcounts the live messages; a post-processed transcript may contain a different number of messages- If post-processing fails,
session_end.datacan also includepostProcessingFailedandpostProcessingError