How can you integrate chatbot Kore.ai Salesforce Agent Transfer

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

Here we will be integrating Kore.ai Salesforce agent transfer. Kore.ai 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 Kore.ai?

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

We can understand that by below flow diagram.

source: https://developer.kore.ai/docs/bots/sdks/using-the-botkit-sdk/

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

Advertisement
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 Kore.ai.

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

liveAgentUrl
organizationId
deploymentId
screenResolution eg.
1920×1080
userAgent eg. 
Mozilla/5.0
apiVersion
language eg. 
en-US
buttonId

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 —

redis-server

Redis-Server

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.

<<HOST_NAME>>/System/SessionId

Headers:

‘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.

<<HOST_NAME>>/Chasitor/ChasitorInit

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

<<HOST_NAME>>/System/Messages/Chasitor/ChatMessage

  • 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.

<<HOST_NAME>>/System/Messages

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

<<HOST_NAME>>/Chasitor/ChatEnd

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

Advertisement

Leave a Reply

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

18 − 9 =