End a Bot Session

If the bot has no more actions to take, the customer can end the session.

1// Build the request to end the bot session.
2BotEndSessionRequest botEndSessionRequest = BotRequest
3    .withEndSession(EndSessionReason.USERREQUEST).build();
4
5// Retrieve the RuntimeSessionId from the sessionId returned by the bot when
6// the session starts.
7RuntimeSessionId runtimeSessionId = new RuntimeSessionId(sessionId);
8
9// Send the request to the bot to end the session.
10BotResponse endSessionResponse = client
11    .endChatSession(config, runtimeSessionId, botEndSessionRequest);

Here’s an example of a text output from the bot’s response when the session ends.

1// Response output
2The chat session ended with reason: ClientRequest