Conversation
Launch chat screen
You can open the chat screen by calling the below function:
Cordova
If you are using native Cordova:
kommunicate.launchConversation((response) => {
//conversation launched successfully
}, (response) => {
//conversation launch failed
});
Ionic
If you are using the ionic framework:
this.kommunicate.launchConversation()
.then((response : any) => { /*sucessfully launched*/ })
.catch((error : any) => {
/*error occurred*/
console.log(error);
});
Launch individual chat thread
You can open an individual chat thread by calling the below function and passing the clientChannelKey
the clientChannelKey is which you got from a new conversation method on success response.
let convObj = {
'clientChannelKey' : clientChannelKey, //pass the clientChannelKey here
'takeOrder' : true //skip chat list on back press, pass false if you want to show chat list on back press
};
Cordova
If you are using native Cordova:
kommunicate.launchParticularConversation(convObj, function(response) {
//Conversation launched successfully
}, function(response) {
//Conversation launch failed
});
Ionic
If you are using the ionic framework:
this.kommunicate.launchParticularConversation(convObj)
.then((response : any) => { /*conversation sucessfully launched*/ })
.catch((error : any) => { /*error occurred*/ });
Start a new Conversation
To start a new conversation first create a conversation object:
let conversationObject = {
'isSingleConversation' : false
};
Then call the conversationBuilder
function.
Cordova
If you are using native Cordova:
kommunicate.conversationBuilder(conversationObject, (clientChannelKey) => {
//The response will be a clientChannelKey which is used for launching a particular conversation.
console.log("Kommunicate create conversation successful the clientChannelKey is : " + clientChannelKey);
},(error) => {
console.log("Kommunicate create conversation failed : " + error);
});
Ionic
If you are using the ionic framework:
this.kommunicate.conversationBuilder(converationObject)
.then((clientChannelKey: any) => console.log("Kommunicate create conversation successful the clientChannelKey is : " + clientChannelKey))
.catch((error: any) => console.error("Error creating conversation." + error));
Create conversation for specific bots
If you have the list of agentIds and botIds, you can pass it in the below conversation object.
var conversationObject = {
'isSingleConversation' : false,
'agentIds':['<AGENT_ID>'], //List of agentIds. AGENT_ID is the emailID used to signup on Kommunicate
'botIds': ['<BOT_ID>'] //List of botIds. Go to Manage Bots(https://dashboard.kommunicate.io/bots/manage-bots) -> Copy botID
};
Then call the conversationBuilder
function.
Cordova
If you are using native Cordova:
kommunicate.conversationBuilder(conversationObject, (clientChannelKey) => {
//The response will be a clientChannelKey which is used for launching a particular conversation.
console.log("Kommunicate create conversation successful the clientChannelKey is : " + clientChannelKey);
},(error) => {
console.log("Kommunicate create conversation failed : " + error);
});
Ionic
If you are using the ionic framework:
this.kommunicate.conversationBuilder(converationObject)
.then((clientChannelKey: any) => console.log("Kommunicate create conversation successful the clientChannelKey is : " + clientChannelKey))
.catch((error: any) => console.error("Error creating conversation." + error));
Start a Unique Conversation
You can create a unique conversation using the below method. A unique conversation is identified by the list of agentIds and botIds used to create the conversation. If the same set of Ids are passed to the below method, then the already created conversation would be returned instead of creating a new conversation:
var conversationObject = {
'agentIds':['<AGENT_ID>'], //List of agentIds. AGENT_ID is the emailID used to signup on Kommunicate
'botIds': ['<BOT_ID>'] //List of botIds. Go to Manage Bots(https://dashboard.kommunicate.io/bots/manage-bots) -> Copy botID
};
Then call the conversationBuilder
function.
Cordova
If you are using native Cordova:
kommunicate.conversationBuilder(conversationObject, (clientChannelKey) => {
//The response will be a clientChannelKey which is used for launching a particular conversation.
console.log("Kommunicate create conversation successful the clientChannelKey is : " + clientChannelKey);
},(error) => {
console.log("Kommunicate create conversation failed : " + error);
});
Ionic
If you are using the ionic framework:
this.kommunicate.conversationBuilder(converationObject)
.then((clientChannelKey: any) => console.log("Kommunicate create conversation successful the clientChannelKey is : " + clientChannelKey))
.catch((error: any) => console.error("Error creating conversation." + error));
Note: Refer this if you want to use other paramters for creating the converstion, like metadata etc
Rich Message
Rich message provide a better overall conversational experience to the users, make the interface look pretty, they also drive more actions from your users and provide a good conversational experience. There are a variety of response types to choose from. For example, you can show images, play videos, provide buttons, list, forms, or card carousels.
Refer the following link to use rich messages in Kommunicate.