Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 Settings > Widget Functionality > Registration & Log In.

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

...

  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:

...

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.

...