Session events
When you build your own client, the conversation runs between the visitor's browser and the voice provider. Send session events so the console can show the session's length, transcript and errors, the same as for the VoisX widget.
Send session events
/widget/v1/analyticsRecords one or more events for a session. You can send several events in one request.
Requires the widget:read permission.
Headers
X-API-KeystringrequiredBody
session_idstringrequiredsession_id from Start a session.agent_idintegerrequiredeventsarrayrequiredevents[].typestringrequiredevents[].timestampstringrequiredevents[].dataobjectoptionalEvent types
type | data fields | What it records |
|---|---|---|
session_start | visitor_id (optional) | The session started. |
session_end | duration_seconds (number) | The session ended and how long it lasted. |
transcript | transcript_data (array of turns) | The conversation. Each turn has role (user or assistant), text and timestamp. |
message | message (string) | One message in the conversation, for the session log. |
error | error_type, message | An error your client hit. |
tool_call_made | none | The agent asked for a tool. |
tool_call_success | none | A tool call succeeded. |
Unknown types are accepted and ignored. Tool calls you run through POST /widget/v1/tools/execute are already counted, so you do not need to send tool_call_made or tool_call_success for them.
Send the transcript event once, with the full conversation, when the session ends. VoisX analyses each transcript it receives to work out the session's outcome, so sending it more than once can repeat that work.
Response fields
successbooleanoptionaltrue when the request was accepted.receivedintegeroptionalpersistedintegeroptionalResponses
widget:read, or is not allowed from this domain.