Skip to main content

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​

POST/widget/v1/analytics

Records one or more events for a session. You can send several events in one request.

Requires the widget:read permission.

Headers​

X-API-Keystringrequired
Your project API key.

Body​

session_idstringrequired
The session_id from Start a session.
agent_idintegerrequired
The agent the session is with.
eventsarrayrequired
The events to record.
events[].typestringrequired
The event type. See the table below.
events[].timestampstringrequired
When the event happened, in ISO 8601.
events[].dataobjectoptional
Extra details for the event type.

Event types​

typedata fieldsWhat it records
session_startvisitor_id (optional)The session started.
session_endduration_seconds (number)The session ended and how long it lasted.
transcripttranscript_data (array of turns)The conversation. Each turn has role (user or assistant), text and timestamp.
messagemessage (string)One message in the conversation, for the session log.
errorerror_type, messageAn error your client hit.
tool_call_madenoneThe agent asked for a tool.
tool_call_successnoneA 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.

tip

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​

successbooleanoptional
Always true when the request was accepted.
receivedintegeroptional
How many events were in the request.
persistedintegeroptional
How many events were recorded. An event that cannot be recorded is skipped and does not fail the request.

Responses​

200
The events were received.
401
The key is invalid, revoked, lacks widget:read, or is not allowed from this domain.
403
The key cannot use this agent, or the agent is in another project.
404
The agent was not found.
422
A required field is missing or has the wrong type.
429
The key's rate limit was reached.
Was this page helpful?
On this page
Try it in the consoleBuild an agent and test it in the Playground.Open console →