Conversation

Overview

This section is dedicated to launching and managing conversations in the chat widget on certain triggers. For example, the chat widget will only appear on the website on click of a specific button. This could be useful if you wish to show support chat only on certain triggers and not all the time.

Conversations

Conversation Settings

Kommunicate provides some parameter to configure the conversation rules when it is created. These parameters can be used to override the conversation rules you have set from dashboard. These parameters can be set using the Kommunicate.updateSettings() methods. The updated setting will be effective from the next conversation user creates by either clicking on the Start new conversation on chat widget or calling the Kommunicate.startConversation().

Below is the sample code to update the conversation setting:

var defaultSettings = {
    "defaultAgentIds": [""],
    "defaultBotIds": [""], 
    "defaultAssignee": "", 
    "skipBotEvent": '[""]', 
    "skipRouting": true,
    "teamId": <TEAM_ID> 
};    
Kommunicate.updateSettings(defaultSettings);  

Below is the detail about the supported parameters:

Parameters

Type

Default value

Descriptions

defaultAssignee

string

Configured routing rules for agents from dashboard

You need to pass the agentId/botId. If nothing is passed the default agent will automatically get selected. NOTE: You need to pass "skipRouting": true with defaultAssignee parameter if you have assigned a default assignee from the conversation rules section

defaultAgentIds

array

Configured routing rules for agents from dashboard

You can pass the default agents that you want to be present in every new conversation created.

defaultBotIds

array

Configured routing rules for bots from dashboard

You can pass the default bots that you want to be present in every new conversation created.

WELCOME_MESSAGE

string

Configured from dashboard

You can pass the default welcome message here and it will override the welcome message which you have set from dashboard. NOTE: It will not override the welcome message sent by your bot.

skipRouting

boolean

false

If you pass this value true then it will skip routing rules set from conversation rules section.

skipBotEvent

array

None

You can pass the bot event names that you want to skip in every new conversation created. Read more about bot events here

teamId

number

All conversations will be assigned to default team.

Assign conversations to a particular team by passing teamId and the conversation assignment will be based your assigned team rules. Get team ID from teammates section

Example : Assigning conversations to a specific bot/agent on certain events

Usecase: A user comes to your website and starts a conversation with support agents. When user navigates to another page you wants to start conversation with another agents or bots. You can achieve this by updating the conversation rules dynamically. Set the appropriate values in above mentioned parameters and Kommunicate will use these parameters while creating the conversation. You can update the empty values when user navigate to previous page to make old conversation rules(set from dashboard) effective. Below is the sample code for the same:



var defaultSettings = {
    "defaultAgentIds": [""], 
    "defaultBotIds": [""], 
    "defaultAssignee": "", 
    "skipRouting": true
};
Kommunicate.updateSettings(defaultSettings);  

Launch conversation List

To launch the chat widget and conversation list, use the following method.

Kommunicate.launchConversation();

How it works ?

  1. Initially, if there are no previous conversations, then it will create a new conversation and open it.

  2. If you have old/previous conversations, it will open the conversation list.

Assign different bot to different website pages

In order to change widget's default settings like default bots in conversation and default assignee, you need to create defaultSettings object with two parameters, defaultBotIds containing list of bot ids which you wish to add in conversation, defaultAssignee having string value to the agent/bot which you wish to assign conversation by default.

(function(d, m){
    
    var defaultSettings = {
    "defaultBotIds": [""], 
    "defaultAssignee": "", 
    "skipRouting":true
    };
    var kommunicateSettings = {
        "appId":"",  
        "automaticChatOpenOnNavigation":false,
        "onInit": function() {
            Kommunicate.updateSettings(defaultSettings); 
        }
    };
    
    var s = document.createElement("script");
    s.type = "text/javascript"; s.async = true;
    s.src = "https://widget.kommunicate.io/v2/kommunicate.app";
    var h = document.getElementsByTagName("head")[0];
    h.appendChild(s);
    window.kommunicate = m;
    m._globals = kommunicateSettings;
})(document, window.kommunicate || {});

Initiate conversation with specific team

To start a conversation with a specific team, one can create defaultSettings object with teamId parameter. These parameters can be set using the Kommunicate.updateSettings() method.

Below is the sample code to update the conversation setting:

(function(d, m){
    var defaultSettings = {
    "teamId": "" 
    };
    var kommunicateSettings = {
        "appId":"",  
        "automaticChatOpenOnNavigation":false,
        "onInit": function() {
            Kommunicate.updateSettings(defaultSettings); 
        }
    };
    var s = document.createElement("script");
    s.type = "text/javascript"; s.async = true;
    s.src = "https://widget.kommunicate.io/v2/kommunicate.app";
    var h = document.getElementsByTagName("head")[0];
    h.appendChild(s);
    window.kommunicate = m;
    m._globals = kommunicateSettings;
})(document, window.kommunicate || {});

Create a new conversation

A conversation can be created using startConversation method. Below is the example code for the same. You can choose to define certain parameters to profile this conversation and allot assignee.


Kommunicate.startConversation(); 

Note: You have to set "automaticChatOpenOnNavigation" parameter to false as this option won't be compatible with startConversation method.


var conversationDetail = {
    "defaultGroupName": "", 
    "agentIds": [""], 
    "botIds": [""], 
    "skipRouting":"true", 
    "assignee":" or " 
};
Kommunicate.startConversation(conversationDetail, function (response) {
    console.log("new conversation created");
});                    

Note: If called with empty parameters it will inherits the conversation rules from conversation settings object. It can be helpful to set conversation rules dynamically. Refer to below example :

var defaultSettings = {
    "defaultBotIds": [""], 
    "defaultAssignee": "", 
    "skipRouting": true
};
Kommunicate.updateSettings(defaultSettings); 


Kommunicate.startConversation(); 

Open a particular conversation

If you wish to open a particular conversation, pass the group ID of that conversation by using the method mentioned below:

Kommunicate.openConversation();

Open chat window when a new message comes

If you want the chat window to pop open when a new conversation comes, add "openConversationOnNewMessage": true in kommunicateSettings object. This will open the chat window when a new message comes.


    var kommunicateSettings = {
        ...
        "appId": "",
        "openConversationOnNewMessage":true
        ...
    };

Start a new session every time a user visits again

Kommunicate expires the user session if a user is anonymous and inactive for 30 days. If a user comes back to your website within 30 days then the old conversations of the user will be visible. If you want to start a new session every time user comes to your website then change the settings in the kommunicate dashboard where all the existing info and previous messages will be removed from the chat widget after a set period of time.

Last updated