Skip to content

SessionEvents

What session.on(name, fn) delivers.

ended: object

The session is over. Fires once. reason is one of client_ended, partner_ended, max_duration, idle_timeout, disconnected, server_shutdown, provider_failure, suspended, service_stopped (the voice service was switched off; start a new session once it is back) or error.

durationMs: number

reason: string

turns: number


error: SessionErrorInfo

A problem. fatal: false means the session goes on (for example audio_unavailable).


event: ServerEvent

Every event from the service, as parsed, for logging or for events the SDK doesn’t map.


interrupted: object

The reply was cut off (the person spoke, or interrupt() was called). heardMs is how much was heard.

heardMs: number

replyId: string


replySentence: object

One sentence of the voice’s reply, with its emotion, as it is spoken.

emotion: string

index: number

replyId: string

text: string


safety: object

The safety layer acted on a turn: the stage, the category (a level, never the text) and the action taken.

action: string

category: string

stage: string

turn: number


state: SessionState

The session’s state changed.


transcript: object

What the person said, once the service has understood the turn. languageStage is the language’s stage; languageBeta is true for any language that is not supported (beta or alpha).

language: string

languageBeta: boolean

languageStage: LanguageStage

text: string

turn: number


warning: object

A heads-up before the session ends, for example secondsLeft before the time limit.

code: string

secondsLeft: number