End a Session

If the bot has no more actions to take, the customer can end the session with this DELETE endpoint. If the service client doesn’t end the chat session, the session stays open for 3 days and then times out. The <session-id> is the ID of the active session you want to end. The <HOST_URL> is the Runtime Base URL field found in the Add Connection dialog when you add the connected app to the bot (see Get Started with Einstein Bots API).

Note: This section describes the endpoint for API version 5 only and can’t be used with earlier versions.

This example shows you how to send a request to end a bot session with this endpoint. Here the host URL is https://runtime-api-na-west.stg.chatbots.sfdc.sh.

The delete request header X-Session-End-Reason is required and must have one of these values.

  • UserRequest
  • Transfer
  • Expiration
  • Error
  • Other

After the client requests to end the session, the bot responds with a session-ended message. Here, the messages object in the response body has the sessionEnded message type.

Now that the chat session has ended, you can clean up any resources allocated to the service client.