Update User Details

Updated 

sprChat('updateUserSettings')

This API can be used when we want to update the details of the current user, or change the current user(authenticate the current anonymous user or logout the current authenticated user) or update the custom fields/context for the current user.

Parameters:

(every parameter is optional unless marked *):

Name

Typescript type

Description

Default Value

userContext

StringTMap<string[]>

Map of custom field ids vs their value that should be updated on the current user

-

user

{

    id: string;

    hash: string;

    email?: string;

    firstName?: string;

    lastName?: string;

    profileImageUrl?: string;

    phoneNo?: string;

}



Current user


Examples 

  1. Updates '_p_abcdef123' custom field’s value as '123' for the current user.

window.sprChat('updateUserSettings', {

   userContext: {
'_p_abcdef123': ['123'],

   }
});

  1. Updates user details for the current anonymous user.

window.sprChat('updateUserSettings', {
  user: {
    firstName:
'live'
    lastName:
'chat',
    email:
'live-chat@sprinklr.com'
  },
});


  1. Updates user details for the current authenticated user.

window.sprChat('updateUserSettings', {
  user: {
    id:
'123',
    hash:
'12adsfasdf1231sadasfasfas1231dgfggf',
    firstName:
'live'
    lastName:
'chat',
    email:
'live-chat@sprinklr.com'
  },
});


  1. If your current user is anonymous, calling the following updates the session by merging the current user and their history with the authenticated user and their history.

window.sprChat('updateUserSettings', {
  user: {
    id:
'123',
    hash:
'12adsfasdf1231sadasfasfas1231dgfggf',
    firstName:
'live'
    lastName:
'chat',
    email:
'live-chat@sprinklr.com'
  },
});


  1. If your current user is authenticated, calling the following changes the session by logging out the authenticated user and clearing their history, and creates a new anonymous user.

window.sprChat('updateUserSettings', {
  user: {},
});