Transfer the Bot Session to Another Target

The bot can send an escalation message to the client or an option to transfer the session to another target because of, for example, an error, or by user request. Another target can be, for example, a different bot, agent, agent queue, Salesforce skill, or Salesforce flow. Let’s stick with the example where the bot greets the customer with a welcome message and a choices menu. See Retrieve the Bot’s Response for the JSON response body.

In this example, the client selects the “Transfer To Agent” option. This sample code shows how the client sends the option as a TextMessage type to the bot. See Send a Message to the Bot.

Retrieve the bot’s message from the response.

Here is an example text output from the bot.

The API itself doesn’t route the bot session to another target. The API only responds with an array of target objects configured by the bot-admin. The client is responsible for transferring the session to one of the targets after receiving an escalation message from the bot. After the client routes the session to another target, the client must send back a transfer success or transfer failed message to the bot.

If the client successfully transfers to an agent, the client must send a message with type TransferSucceededRequestMessage to the bot, as described in the next section. If it fails, the client must send a message with type TransferFailedRequestMessage to the bot. The client can then End a Bot Session.

Here is an example of a transfer success message from the client to the bot.

If you extract the text output from the bot’s response, the output must be empty for a transfer success response.

Here’s an example of a transfer failed message from the client to the bot. If the bot sends an escalation message but the client isn’t able to transfer the customer to the directed source, the client must send a transfer failed message to the bot.

Here is an example text output from the bot if the client sends a transfer failed message.