How can you integrate chatbot Salesforce Agent Transfer

“Bots and Agents That Work Together to Create Happy Customers” —

Here we will be integrating Salesforce agent transfer. is the enterprise conversational chatbot building platform, which helps customers to build chatbots for different domains. It helps to reduce the number of hours an agent spent on answering customer queries.

Automate first-line customer support and lead gen with bots that can seamlessly hand off dialogs, based on conversation context, to human agents in real-time.

When Is a Human Agent Required?

Chatbots and humans have very different and distinct strengths — and both are needed to provide excellent customer experiences. While chatbots can handle a large volume of customer requests and respond instantly, 24 hours a day, 7 days a week, they aren’t perfect. Things can and do happen. Live agent transfer allows you to make the most of what each has to offer with virtually zero impact on the customer.

How to Integrate?

We need to use a component called BotKit.

What is BotKit? How can I use BotKit with

We can assume that BotKit is a middleware between and your chatbot instance.

We can understand that by below flow diagram.

source: exposes an event called “onAgentTransfer”. Which we can use as a component in botbuilder.

Dialog “AgentTransfer” where we have the component for SaleforceAgent Transfer

When dialog flow reaches to this component, it will trigger event onAgentTransfer, which we need to capture in BotKit.

Using Agent Transfer Dialog as Default dialog ( if the user’s intent is not understood)

Now we need to customize GitHub BotKit for Salesforce agent Transfer.

We need to install these for the demo before running

  1. ngrok — to expose our local BotKit application to the cloud.
  2. NodeJs — BotKit is available as NodeJs application. We need to have NodeJs installed.
  3. Salesforce configuration details —

screenResolution eg.
userAgent eg. 
language eg. 

You can get all this information from Salesforce developer/admin account.

4. Redis Server — We will be storing information about live agent transfers to Redis in order to do communicate.

Starting Redis-Server

command —



Once we have all of these ready, we can start our NodeJs BotKit application.

staring BotKit Application

and using Ngrok we will get URL.

Enable Agent Transfer in Bot Builder.

Salesforce APIs for Communication

Headers :

  • Get Session — This would be the first API we will call in order to communicate.



‘X-Liveagent-Affinity’: ‘null’,
‘X-Liveagent-Api-Version’: apiVersion

  • Initialize Chat — Once we get the session, we need to initialize chat, along with pre-populated entities for the case or contact creation or attaching. This will decide which queue or Button ID your conversation should go.


  • Send Message — We need to call this API along with session id in order to deliver messages to Salesforce Agent.


  • Get Pending Messages — In order to receive messages or events (there are multiple events available from Salesforce Agent Chat — ChatEstablished, ChatMessage, ChatEnded, QueueUpdate, etc.) for getting latest messages or event, we will be calling this API in long polling manner.


  • End Chat — this API would be called when we need to end the communication to the agent.


For more details on API, here is the official documentation from Salesforce.

How would experience look like?

For Agents :

For user?

any questions? Drop comments

Note: This blog was originally published on medium


Leave a Reply

Your email address will not be published. Required fields are marked *

20 − 5 =