Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
panelIconIdf3de15fc-91a3-428f-9029-3800cee956e3atlassian-info
panelIcon:ichatinfo:
panelIconText:ichatinfo:
bgColor#F4F5F7

This page is about Chat for JSM Cloud. Using Server or Data Center? Click here.

Supporting customers is even faster and more seamless with the auto-login integration. With this feature, once a customer logs in to your website or portal, they will automatically be logged in to the Chat Widget without having to enter separate credentials. This makes the customer's experience seamless and removes a potential blocker to them getting in touch with you. It also enables agents to respond more quickly.

The auto-login feature requires several changes on the front end and back end of the service that is going to be integrated.

Prerequisites

  1. A secret key is used to verify that the login request is valid and coming from your (client’s) back end. Each service desk project has its own secret key. To obtain the key, open your project, and go to Project Settings > Chat

...

  1. for JSM >

...

  1. Authentication > Auto Login on Website.

  2. Here, enable the Auto Login feature, and then click Generate secret key:

...

  1. image-20240216-094307.pngImage Added
  1. The secret key should be stored on the back end.

Logging in

While performing user login on the website, the service should generate and issue a JWT access token for a chat and sign it with the secret key, as shown in the example below:

...

The service’s front end should receive this token and call Chat’s SSO login API:

Code Block
const chatWidget = document.querySelector('chat-widget');
chatWidget.onload = async function () {
        await chatWidget.loginWithToken(token);
};
Expand
titleOld code snippet:
Code Block
languagehtml
try {
  await spartezSupportChat.sso.login(token);
} catch (exception){
  //handle exception
}

In order to make it work, we need to make sure that Chat has been correctly initialized before the login operation. To do this, we can use initCallback from the spartezSupportChat object – see Set Up Chat Widget on Your Website.If you don’t want to show Chat Widget to users until they log in, you can add the following call to the code above:

Code Block
chatWidget.show();

If you want to show the Chat Widget only to certain users, you can filter by email domain:

Code Block
chatWidget.onload = function () {
   // Check if user is in a correct domain. 
   // `user.email` might be `user.emailAddress` or similar depending on your data model
   if (user.email && user.email.includes('@appfire.com')) {
        chatWidget.loginWithToken(token);
   }
};

During the login operation, an error may occur. In that case, an exception will be thrown. To get the error description, you can access exception.message property.

...

To log out, the service’s front end should call await chatWidget.logout();.

Expand
titleOld code snippet:

await spartezSupportChat.sso.logout();

...