Chatbot Overview
Conversational Bots
Intents & Entities
Intelligent Bots
Kore.ai's Approach
Kore.ai Conversational Platform
Bot Concepts and Terminology
Natural Language Processing (NLP)
Bot Types
Bot Tasks
Starting with Kore.ai Platform
How to Access Bot Builder
Working with Kore.ai Bot Builder
Building your first Bot
Getting Started with Building Bots
Using the Dialog Builder Tool
Creating a Simple Bot
Release Notes
Latest Updates
Older Releases
Bot Builder
Creating a Bot
Design
Develop
Storyboard
Dialog Task
User Intent Node
Dialog Node
Entity Node
Supported Entity Types
Composite Entities
Supported Time Zones
Supported Colors
Supported Company Names
Message Nodes
Confirmation Nodes
Service Node
Custom Authentication
2-way SSL for Service nodes
Script Node
Agent Transfer Node
WebHook Node
Connections & Transitions
Managing Dialogs
Prompt Editor
Alert Tasks
Alert Tasks
Ignore Words and Field Memory
Digital Views
Knowledge Graph
Terminology
Building
Generation
Importing and Exporting
Analysis
Knowledge Extraction
Small Talk
Action & Information Task
Action Tasks
Information Tasks
Establishing Flows
Natural Language
Overview
Machine Learning
ML Model
Fundamental Meaning
NLP Settings and Guidelines
Knowledge Graph Training
Traits
Ranking and Resolver
NLP Detection
Bot Intelligence
Overview
Context Management
Session and Context Variables
Context Object
Dialog Management
Sub-Intents
Amend Entity
Multi-Intent Detection
Sentiment Management
Tone Analysis
Sentiment Management
Default Conversations
Default Standard Responses
Channel Enablement
Test & Debug
Talk to Bot
Utterance Testing
Batch Testing
Record Conversations
Publishing your Bot
Analyzing your Bot
Overview
Dashboard
Custom Dashboard
Conversation Flows
Bot Metrics
Advanced Topics
Bot Authorization
Language Management
Collaborative Development
IVR Integration
koreUtil Libraries
Universal Bots
Defining
Creating
Customizing
Enabling Languages
Smart Bots
Defining
Sample Bots
Github
Asana
Travel Planning
Flight Search
Event Based Bot Actions
Bot Settings
Bot Functions
General Settings
PII Settings
Customizing Error Messages
Bot Management
Using Bot Variables
API Guide
API Overview
API List
API Collection
SDKs
SDK Overview
SDK Security
SDK App Registration
Web SDK Tutorial
Message Formatting and Templates
Mobile SDK Push Notification
Widget SDK Tutorial
Widget SDK – Message Formatting and Templates
Web Socket Connect & RTM
Using the BotKit SDK
Installing
Configuring
Events
Functions
BotKit SDK Tutorial – Agent Transfer
BotKit SDK Tutorial – Flight Search Sample Bot
Using an External NLP Engine
Bot Administration
Bots Admin Console
Dashboard
User Management
Managing Users
Managing Groups
Managing Role
Bots Management
Enrollment
Inviting Users
Bulk Invites
Importing Users
Synchronizing Users from AD
Security & Compliance
Using Single Sign-On
Security Settings
Cloud Connector
Analytics
Billing
How Tos
Creating a Simple Bot
Creating a Banking Bot
Transfer Funds Task
Update Balance Task
Context Switching
Using Traits
Schedule a Smart Alert
Configuring Digital Views
Custom Dashboard
Custom Tags to filter Bot Metrics
Patterns for Intents & Entities
Build Knowledge Graph
Global Variables
Content Variables
Using Bot Functions
Configure Agent Transfer
  1. Home
  2. Docs
  3. Bots
  4. How Tos
  5. How To Configure Agent Transfer

How To Configure Agent Transfer

One of the frequently asked questions is how to transfer a chat to a human agent from the Bot. This is especially necessary if your bot is in the space of customer service. Chatbots are not meant to completely replace humans. Many times chatbot will fail to answer satisfactorily or user would just want to talk/chat to a human from the beginning. When this happens the chatbot should transfer the chats to a human agent or a customer care representative. But how to achieve that?

In this article, we will give an overview of how we can integrate a live chat into our bot using Kore.ai Agent Transfer. The source code for the Agent Transfer is available at Kore.ai github repo: https://github.com/Koredotcom/BotKit

Overview

Our Bot would be the central piece to the entire solution. Apart from performing all its normal functionality, our bot would also act as a proxy between user and agent.

  • Bot: Chat Bot that the Users interact.
  • Users: Users are the customers who would be using this Bot.
  • Agent: Agents are humans who would chat with the users. Agent will also need a chat window. For this we will use liveperson/livechat software.

Prerequisites

  • A fully functional Bot (we will be using a Banking Bot).
  • Download BotKit SDK from Kore’s github
  • Download and Install the Node.js. The BotKit SDK requires node.js to run on the same server where the SDK is installed.
    1. Go to https://nodejs.org/en/download/ and select your OS as a .pkg file type for Mac and .msi file type for Windows.
    2. In a Terminal window, run the node -v command to verify installation and version, for example, v6.10.2.
  • A test callback server application. We will be using NGROK from https://dl.equinox.io/ngrok/ngrok/stable to simulate the callback server application. Following are the steps to install NGROK:
    1. Open https://dl.equinox.io/ngrok/ngrok/stable.
    2. Download and install the ngrok file for your operating system.
      • Downloading NGROK on Windows:
        1. Download the zip file for your Windows machine 32-bit or 64-bit
        2. Unzip and run the ngrok.exe file to install ngrok.
      • Downloading NGROK on mac:
        1. Press Command+Space and type Terminal and press enter/return key.
        2. Run in Terminal app:
          ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null and press enter/return key.
          If the screen prompts you to enter a password, please enter your Mac’s user password to continue. When you type the password, it won’t be displayed on the screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish.
        3. Run brew cask install ngrok
  • A live agent software. We will be using LiveChatInc.com. You can use your own LiveChat subscription or set up a free 30-day trial account at LiveChatInc.com by entering your business email in the Start using LiveChat now!. Sign up and create an account.

Design and Configuration

  1. As a Bot developer, open Kore.ai Bot Builder – https://bots.kore.ai/botbuilder
  2. Select the Bot for which Agent Transfer needs to be configured.
  3. Open or create a dialog task (Support Call Back) and add an Agent transfer node.
  4. Enter a Name (LiveChat) and Description and Save.
  5. You will see a message ‘SDK is not currently configured/Subscribed. Please go to API Extensions to configure the SDK.’. For now ignore this message as we will be showing how to configure SDK, later in this article.
  6. From the Bot Builder screen traverse to API Extensions -> Agent Transfer
  7. In the App Name section, select an existing app from the list or use the Create App option to create a new app.
  8. Make a note of the Bot ID, Client ID and Client Secret keys.
  9. Enter the Callback URL of your application, to be invoked by BotKIt SDK events. Since we are using NGROK, we will show how to obtain the callback URL:
    1. In a Terminal Window, start ngrok to monitor port 8003 using the following command: ngrok http 8003.
    2. Copy ngrok forwarding URL. It will be in the format – http://XXXXXXaa.ngrok.io
    3. Use this forwarding URL as the call back URL and save.
      Note: The forwarding URL changes whenever the ngrok is restarted. Make sure you make the changes to the callback URL every time ngrok is restarted.
  10. The agent transfer is configured at the dialog level. You can open the dialog task, and open agent transfer node to see that the configuration is saved as shown below. You can select the Events required (see below for details)
  11. Install any live agent software eg Livechat, Liveperson, Concentrix, Vayusphere etc depending on your enterprise requirement and license availability. Since we are using LiveChat, we will should you how to obtain the license details needed for Agent Transfer:
    1. Sign in to your LiveChat account.
    2. Go to Settings from the left navigation and select chat link.
    3. Copy the URL and note the license code. If the URL is https://lc.chat/now/104xx297/ and then the license code is 104xx297
  12. Open the downloaded BotKit SDK folder and do the following:
    • Edit livechatapi.js:
      1. Give the respective botId and botName of your bot, which you have copied earlier.
      2. This JS file contains 3 API’s of Kore – Initialization, Send Message, Get Message. If required, any new API’s written for human agent transfer should be put in here.
        Example: If closing connection is required, then close connection api written needs to go into livechatapi.js
    • Edit config.json
      1. Client ID, Client Secret key, respective server ports running and liveagent license of the third-party server goes here.
      2. Client Id, Client Secret can be copied from Events and Extensions – Agent Transfer.
      3. ngrok forwarding url can be copied from ngrok running instance. It is the call back url. This should be the URL entry.
      4. Liveagentlicense is the code given in the chatlink of livechat

    • Edit LiveChat.js
      • Give the respective botId and botName of your bot, which you have copied earlier and save
    • Edit app.js
      1. Add the following line sdk.registerBot(require('./LiveChat.js'))
      2. Delete any existing sdk.registerBot statements, if not needed

Execution

  1. Open a terminal window and run the BotKit SDK by entering the command:
    node app.js
  2. Please make sure to install all the missing modules for running the server successfully without any errors as shown below.
    Example, if error “method url-template, node-schedule are missing” is shown, then install the above modules using command
    npm install <module-name> for windows, sudo npm install <module-name> for mac
  3. ngrok and node.js server will be running in different terminals.
  4. When user initiates the chat from the bot, bot transfers the call to an agent and sends a message to the user
  5. Agent receives a notification about this on the livechat
  6. Now connection between agent and the user has been established and the conversation continues.

Events

Note: The events and methods required for sending messages from User, bot and transferring to Agent are outlined in LiveChat.JS

  1. on_user_message event is triggered when a user sends a message and this message is sent to the bot using sendBotMessage method.
  2. on_bot_message is triggered when bot sends a message and this message is sent to the user using SendUserMessage method.
  3. on_agent_transfer event is triggered when the service agentTransfer node is triggered in bot. And this event connects to the agent using connectToAgent method, which internally calls initChat API
  4. gethistory method, gives the chat history of the user with the bot to the transferred agent
  5. scheduleJob is run for every 5 secs and it polls for the pending messages from the Agent, which internally calls getPendingMessages
  6. getPendingMessages gets all the pending messages from Agent and delivers it to the User
  7. chat_closed gets triggered when the agent closes the chat with the user.
Menu