Developer Docs | Kommunicate

Developer Docs | Kommunicate

  • Docs

›iOS

Web

  • Installation
  • CMS Installation
  • Authentication
  • Conversation
  • Conversation Assignment
  • Customization
  • Localization
  • Logout
  • Troubleshooting

Android

  • Installation
  • Authentication
  • Push Notification
  • Conversation
  • Customization
  • Localization
  • Logout
  • Troubleshooting

iOS

  • Installation
  • Authentication
  • Push Notification
  • Conversation
  • Customization
  • Localization
  • Logout
  • Troubleshooting

React Native

  • Installation
  • Authentication
  • Push Notification
  • Conversation
  • Customization
  • Logout

Flutter

  • Installation
  • Authentication
  • Customization
  • Conversation
  • Push Notification
  • Localization

Ionic/Cordova/Phonegap

  • Installation
  • Authentication
  • Push Notification
  • Conversation
  • Customization
  • Localization
  • Logout
  • Resolving Errors

Ionic/Capacitor

  • Installation
  • Authentication
  • Push notification
  • Customization

Rich Messages

  • How To Use
  • Types of Rich Messages

Bots

  • Bot setup
  • Dialogflow Integration
  • Lex Integration
  • Kompose Bot Builder
  • IBM Watson Integration
  • Custom Bot Integration
  • Import Kompose Bot
  • Bot Samples

Integrations

  • Zapier
  • WhatsApp

Platform APIs

  • Authentication
  • Endpoints

Dashboard Features

  • Analytics
  • Conversations
  • Users
  • Bot Integration
  • Helpcenter
  • Settings

Configuration

  • Email Fallback
  • Webhooks
  • Access Token URL

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:

// Pass an instance of the current UIViewController in the 'from' argument.
Kommunicate.createAndShowConversation(from: self) { error in
    guard error == nil else {
        print("Conversation error: \(error.debugDescription)")
        return
    }
    // Success
}

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.


let conversationId = "<pass a conversation ID>"
let message = KMMessageBuilder()
    .withConversationId(conversationId)
    .withText("Message from the user.")
    .build()

Kommunicate.sendMessage(message: message) { error in
    guard error == nil else {
        print("Failed to send message: \(String(describing: error?.localizedDescription))")
        return
    }
    Kommunicate.showConversationWith(groupId: conversationId, from: self) { shown in
        print("Conversation shown: \(shown)")
    }
}

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.

KMPushNotificationHandler.shared.dataConnectionNotificationHandlerWith(Kommunicate.defaultConfiguration)
let kmApplocalNotificationHandler: KMAppLocalNotification =  KMAppLocalNotification.appLocalNotificationHandler()
kmApplocalNotificationHandler.dataConnectionNotificationHandler()

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.

  Kommunicate.showConversations(from: self)

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.

let kmConversation = KMConversationBuilder()
    // Optional. If Agent Id is not set, then default agent will
    // automatically get selected. AGENT_Id is the email Id used to signup
    // on Kommunicate dashboard.

    //  To add the agents to conversations directly pass the AgentId parameter
    .withAgentIds( ["<AGENT_IDS>"])
     
    // Using BotIds parameter the bots can be added to the conversations 
    .withBotIds(["<BOT_IDS>"])

    // To set the conversation assignee, pass AgentId or BotId.
    .withConversationAssignee("<AGENT_ID/BOT_ID>") 

    // To pass metadata
    .withMetaData(["key":"value"])
    
    // To set the custom title
    .withConversationTitle("Support query 1")

    .useLastConversation(false)
    .build()

Kommunicate.createConversation(conversation: kmConversation) { result in
    switch result {
    case .success(let conversationId):
        print("Conversation id: ",conversationId)
    // Launch conversation
    case .failure(let kmConversationError):
        print("Failed to create a conversation: ", kmConversationError)
    }
}

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.

 Kommunicate.showConversationWith(
     groupId: conversationId,
     from: self,
     showListOnBack: false, // If true, then the conversation list will be shown on tap of the back button.
     completionHandler: { success in
     print("conversation was shown")
 })

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:

Kommunicate.showConversationWith(
    groupId: conversationId,
    from: self,
    prefilledMessage: "This message will be prefilled in the input text bar",
    completionHandler: { success in
        print("conversation was shown")
    }
)

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.

  • Rich Messages
← Push NotificationCustomization →
  • Create and Launch Conversation
  • Sync conversations on app launch
  • Custom Flow
  • Rich Message
Facebook Open Source

IndiQube Octagon
Site No. 643, 80 Feet Road,
4th Block, Koramangala,
Bengaluru, Karnataka,
India, 560034

(+1) (310) 402-2374
support@kommunicate.io

Docs
WebAndroidiOSIonic/PhonegapReact NativeFlutter
Product
Pricing and FAQsRequest Demo
Social
FacebookTwitterLinkedinYoutube
Copyright © 2022 Kommunicate.io.