Developer Docs | Kommunicate

Developer Docs | Kommunicate

  • Docs

›React Native

Web

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

Android

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

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

Ionic/Cordova/Phonegap

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

Rich Messages

  • How To Use
  • Types of Rich Messages

Bots

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

Integrations

  • Zapier

Platform APIs

  • Authentication
  • Endpoints

Dashboard Features

  • Analytics

Configuration

  • Email Fallback
  • Webhooks
  • Access Token URL

Authentication

To authenticate a user you need to create a user object and then pass it to the login function. The User object has the following properties:

parametersdescription
userIdUnique ID for the user
displayNameDisplay name of the user. Agents will identify users by this display name
emailEmail ID of logged in user
passwordUser's password
imageLinkThe image of the end-user, which will be visible to the agents in the kommunicate dashboard
authenticationTypeIdPass 1 for authentication from kommunicate
APP_IDPass your APP_ID here
deviceApnsType0 for development, 1 for release

There are 2 ways to Login

1. Visitors

Whenever users come to your app and starts the chat, you can assign them a random ID. This behaviour is best suited for anonymous user. Add below function to generate a random userId:

 public getRandomId() : string {
    var text = "";
    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    for (var i = 0; i < 32; i++)
        text += possible.charAt(Math.floor(Math.random() * possible.length));
    return text;
}

Then create the User object using random Id:

 var kmUser = {
      'userId' : this.getRandomId(),
      'applicationId' : '<APP_ID>',  //replace this with your APP_ID from Kommunicate Dashboard
      'deviceApnsType' : 0    //Set 0 for Development and 1 for Distribution (Release)
      };

Then call the loginUser function:

RNKommunicateChat.loginUser(kmUser, (response, message) => {
            if(response == 'Success') {
                console.log(message);
            } else if (response == 'Error') {
                console.log(message);
            }
        });

2. Logged In Users

If the user is already logged in to your app, then pass the user details to create a user object:

    var kmUser = {
        'userId' : this.userId,   //Replace it with the userId of the logged in user
        'password' : this.password,  //Put password here
        'authenticationTypeId' : 1,
        'imageLink' : <image-link-for-user>,
        'applicationId' : '<APP_ID>',  //replace this with your APP_ID from Kommunicate Dashboard
        'deviceApnsType' : 0    //Set 0 for Development and 1 for Distribution (Release)
    };

Then call the loginUser function:

RNKommunicateChat.loginUser(kmUser, (response, message) => {
            if(response == 'Success') {
                console.log(message);
            } else if (response == 'Error') {
                console.log(message);
            }
        });

You can check if the user is logged in or not by calling the isLoggedIn function:

 RNKommunicateChat.isLoggedIn((response) => {
                  if(response == "True") {
                    //the user is logged in
                  } else {
                    //user is not logged in
                  }
                });

Getting the Logged in User

You can get the details of the logged in user as an object. Simply call the following function:

RNKommunicateChat.getLoggedInUser((response, obj) => {
        if(response == 'Error') {
          return;
        } else if(response == 'Success') {
          var user = JSON.parse(obj);
          //do whatever you want with this user
        }
      });
← InstallationPush Notification →
  • There are 2 ways to Login
    • 1. Visitors
    • 2. Logged In Users
  • Getting the Logged in User
Facebook Open Source

710 East Wing Street,
Arlington Heights, IL 60004,

(+1) (310) 909-7458
hello@kommunicate.io

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