Developer Docs | Kommunicate

Developer Docs | Kommunicate

  • Try For Free
  • Docs

›React Native

Web

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

Android

  • Installation
  • Authentication
  • Push Notification
  • Conversation
  • Customization
  • Localization
  • Logout
  • Migration
  • 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
  • Troubleshooting

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
  • WhatsApp 360Dialog
  • WhatsApp Twilio
  • WhatsApp Cloud API

Platform APIs

  • Authentication
  • Endpoints

Dashboard Features

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

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

Ready to automate more than 80% of your customer support?

Try for Free
  • support@kommunicate.io
  • United States
    (+1) (310) 402-2374
  • India
    (+91) 974-057-0196
  • Docs
    • Web
    • Android
    • iOS
    • Ionic/Phonegap
    • React Native
    • Flutter
  • Product
    • Kompose Chatbot Builder
    • Live Chat
    • Integrations
    • Helpcenter
    • Dialogflow Integration
    • Features
    • Pricing and FAQs
    • Get Demo
  • Resources
    • Chatbots Templates
    • Blog
    • Kommunity
    • Support Metrics
    • Free SaaS Icons
    • ROI Calculator
    • Comparison
  • Company
    • About Us
    • Partner Program
    • Terms of Service
    • Privacy Policy
    • Jobs
    • SLA
    • DPA
  • Support
    • Knowledge Base
    • Docs
    • Stack Overflow
    • API Status
    • Contact Us
Software Advice Frontrunners for Live Chat Mar-22crozdesk badgeCapterra Shortlist for Live Chat Mar-22GetApp Category Leaders for Live Chat Mar-22GDPR compliant - GDPR Copy 12Created with Sketch.COMPLIANTG2 reviews badge
Copyright © 2023 Kommunicate.io