Conversation
In this section you will learn how to create and launch the conversation.
Create and Launch Conversation
One of the easiest ways to create and launch the conversation is to use the below method:
If there are no conversations present, then this method will create a new conversation where the default agent and the logged in user will be present. If a conversation is already there, then it will open that conversation. In case there are multiple conversations present then the conversation list will be shown to the user.
For passing agents or bots, you’ve to check out the New Conversation section
If you want to customise it like you want to create your own flow, then check out the Custom Flow
section below.
Send a message programmatically
You can send a message programmatically, it will be useful when you want to send a message on the user’s behalf. The following code snippet shows how you can send a message and open that conversation where the message was sent.
Sync conversations on app launch
Below code is used to sync conversations from server whenever app is launched. Put below lines in your AppDelegate
's didFinishLaunchingWithOptions
method.
Custom Flow
Using this method you can create your own custom conversation flow. Let's say you want to create a new conversation every time when the user clicks on support, then use the API mentioned in the New Conversation
section below.
Open Conversation List
To open a list of conversations use below method. Reference to current view controller needs to be passed.
New Conversation
To create a new conversation, use createConversation
method as shown below. It allows you to create a new conversation by combining different options using KMConversationBuilder
.
Open Conversation
Open any particular conversation by passing the conversationId
and reference to current view controller. You will get the conversationId after creating a conversation as described in the New Conversation section.
Set prefilled text while opening a conversation
The prefilled text can be set while opening a conversation. This will be shown in the input text bar, so the user has to tap the send button instead of typing a message. This will be useful if you are launching a chat from a particular screen where you'll know what a user will be typing. We've added this in the showConversation
API as shown below:
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.
Last updated