Skip to main content

Overview

The finish() method marks a session as finished when its conversation is over. Finishing sets the session status to COMPLETED and closes it. Finishing also makes the session eligible for evaluation right away. A Monitor scores only closed sessions, so an explicit finish gets the session picked up on the next scan instead of waiting for the product’s inactivity auto-close window.

Parameters

string
required
The ID of the session to finish.
string
Free-text reason the conversation ended (for example GOAL_ACHIEVED). When omitted, the default FINISHED is sent, because the API requires a non-empty stopping reason.

Returns

Returns the finished Session object, with status COMPLETED.

Example

To send the default stopping reason, omit the argument:

Notes

Only call finish() when the conversation is truly over. A finished session is closed, so a later attempt to append a trace follows the product’s closed-session policy. By default the trace is kept and the session reopens for a fresh score; the policy can also be set to drop the trace silently, or to reject it with an error. See Session.
To mark a session as failed instead of completed, use Update Session with status="FAILED" (for example galtea.sessions.update(session_id=..., status="FAILED", error="...")). Setting error alone records the message but leaves the session open.