KustomerCore.login()

Authenticates a customer and fetches their session data.

πŸ“˜

Guide: Authenticate chat πŸ“™

Visit Authenticate chat to learn how to authenticate chat with a secure JWT token.

If you have embedded our chat widget behind a login, or if you want to allow users to see their past conversations from a different device, you can authenticate them with KustomerCore.login().

πŸ‘

First, initialize chat

You must initialize with KustomerCore.init() before you can execute any additional Core SDK methods

Examples

// Login a customer
KustomerCore.login({
  jwtToken: 'SOME_JWT_TOKEN'
});


// Login a customer and run a callback after the login
KustomerCore.login({
  jwtToken: 'SOME_JWT_TOKEN'
}, function (loginCallbackResponse, error) {
  if (!error) {
    console.log('User was authenticated!');
  }
});

Syntax

KustomerCore.login(options, function(callbackResponse, error))
ParameterTypeDescription
optionsObjectRequired

An object containing the secure JWT token to authenticate the user with. More information on the token is listed below.
function(callbackResponse, error)FunctionOptional

A callback that is run after KustomerCore.login() completes.

callbackResponse is an object returned to the callback function. See the callbackResponse section below to see the properties of the object.

error is either undefined or a native JavaScript Error object.

options

PropertyTypeDescription
jwtTokenStringRequired

This is a secure token that contains information about the user you want to authenticate.

To learn about how to generate this token for Kustomer, see Generate a JWT Token.

To learn more about JSON Web Tokens, see https://jwt.io/.
brandIdStringOptional

You can override the default brand setting in your Kustomer Chat Settings by passing in a brandId.This is passed to init on a successful login
assistantIdStringOptional

By passing in an assistantId, you can override the default assistant setting in your Kustomer Chat Settings. This is passed to init on a successful login

callbackResponse

These are the fields that will be returned in the login callback response.

KeyTypeDescription
identifiedBooleanRequired

This says whether or not the user was identified successfully.
customerIdStringRequired

This is the customer's unique ID in Kustomer.
emailStringOptional

This is the customer's email address.
externalIdStringOptional

This is the customer's unique external ID.