Conversation
Launch chat screen
You can open the chat screen by calling the below function:
RNKommunicateChat.openConversation((response, message) => {
if(response == 'Error') {
console.log(message);
} else {
//chat screen launched successfully
}
});
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 the buildConversation
method "Success"
response message object.
let clientChannelKey = "clientChannelKey" //pass the clientChannelKey here
let takeOrder = true //skip chat screen on back press, pass false if you want to show chat screen on back press
RNKommunicateChat.openParticularConversation(clientChannelKey, takeOrder, (response, responseMessage) => {
if(response == 'Error') {
console.log(message);
} else {
//conversation launched successfully
}
});
Start a new Conversation
You can start a new conversation by using the below function:
let conversationObject = {
'isSingleConversation' : true //passing true will start the same conversation everytime
};
RNKommunicateChat.buildConversation(conversationObject, (response, responseMessage) => {
if(response == "Success") {
console.log("Kommunicate create conversation successful the clientChannelKey is : " + responseMessage);
} else {
console.log("Kommunicate create conversation failed : " + responseMessage);
}
});
If you have the list of agentIds and botIds, you can pass it in the below conversation object for create the conversation use the below method:
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
'conversationAssignee': '<AGENI_ID / BOT_ID> ' //Should be either an agent Id or a botId. If set, will assign the conversation to the agent or bot thus skipping the routing rules set in the dashboard.
};
RNKommunicateChat.buildConversation(conversationObject, (response, responseMessage) => {
if(response == "Success") {
console.log("Kommunicate create conversation successful the clientChannelKey is : " + responseMessage);
} else {
console.log("Kommunicate create conversation failed : " + responseMessage);
}
});
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
};
RNKommunicateChat.buildConversation(conversationObject, (response, responseMessage) => {
if(response == "Success") {
console.log("Kommunicate create conversation successful the clientChannelKey is : " + responseMessage);
} else {
console.log("Kommunicate create conversation failed : " + responseMessage);
}
});
Note: Refer this if you want to use other paramters for creating the converstion, like metadata etc
To update the teamId of a conversation, use the below method:
RNKommunicateChat.updateTeamId({
//'conversationId': <conversation id>,
'clientConversationId': '<client conversation id>',
'teamId': '<team id>'
})
We can pass either conversationID (integer) or clientConversationID (string) in the object. Once team is updated, conversation will be assigned to that team.
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.