Article: User Recognition Through Single Sign-On Integration for Bot Interactions

Use case:
The concept revolves around the bot being pre-identified through Single Sign-On (SSO) so that, for instance, upon entering the website with my credentials, the bot warmly greets me by my name.

Solution:
To achieve this use case we recommend to use a custom WebSdk.

Please Click Here to refer the official Documentation of WebSDK

The below code can be used in 2 different user login scenarios as per the current requirement to authenticate the user.

Below are the two Scenario’s:

  1. Enabling users engaging with the bot to authenticate upon accessing the website:
  • In this situation, the process involves integrating our code into the WebSdk code within the webpage (through HTML).
  • This implementation on the website allows users to log in, with their login information stored in cookies.
  • The bot recognizes the user’s authentication through the information stored in the cookies.
  1. Facilitating user authentication during bot interactions:
  • In this approach, you need to incorporate an ‘Authenticate’ option within the bot on the webpage.
  • When users click on this option, they are directed to an authentication page.
  • The below provided code must be utilized in this context, as it reads the cookies, providing the bot with sufficient information to verify the user’s authenticity.

Code:

function getCookie(name) {
// Split the cookies into an array
const cookiesArray = document.cookie.split('; ');

// Iterate through the array to find the desired cookie
for (const cookie of cookiesArray) {
const [cookieName, cookieValue] = cookie.split('=');

// Remove leading spaces
const trimmedCookieName = cookieName.trim();

// Check if the current cookie is the one you're looking for
if (trimmedCookieName === name) {
return cookieValue;
}
}

// Return null if the cookie is not found
return null;
}

// Example usage
const myCookieValue = getCookie('myCookie');
console.log('Cookie Value:', myCookieValue);

botOptions.userIdentity = myCookieValue || 'userIdentity';// Provide users email id here
1 Like