If the bot has no more actions to take, the customer can end the session.
// Build the request to end the bot session.
BotEndSessionRequest botEndSessionRequest = BotRequest
.withEndSession(EndSessionReason.USERREQUEST).build();
// Retrieve the RuntimeSessionId from the sessionId returned by the bot when
// the session starts.
RuntimeSessionId runtimeSessionId = new RuntimeSessionId(sessionId);
// Send the request to the bot to end the session.
BotResponse endSessionResponse = client
.endChatSession(config, runtimeSessionId, botEndSessionRequest);
Here’s an example of a text output from the bot’s response when the session ends.
// Response output
The chat session ended with reason: ClientRequest