Authentication

The messaging Web Widget allows authentication of users so that their identity can be verified by agents using Zendesk.

Login

zE("messenger", "loginUser", function (callback) {  callback("new-jwt-for-user")})

If your application has a login flow, or if a user needs to access the same conversation from multiple devices, you can use the loginUser API.

You can associate users with your own user directory by issuing a JWT credential during the login flow. For information on creating signing keys, see Authenticating end users in messaging. For information on creating JWT tokens, see Enabling authenticated visitors for messaging with Zendesk SDKs.

To properly initialize the Web Widget, call the login function as soon as the user logs into your website and their authentication is verified. This ensures the widget functions with the correct authenticated user flow once it is opened, either through end user interaction with the launcher or by calling the open function.

Expiring JWTs

If you want to generate credentials that expire after a certain amount of time, using JWTs is a good way to accomplish this.

The exp (expiration time) property of a JWT payload is honored by the messaging Web Widget. A request made with a JWT which has an exp that is in the past is rejected.

Keep in mind that using JWTs with exp means you need to handle regeneration of JWTs in the function that you provide when calling the loginUser API.

Logout

zE("messenger", "logoutUser")

Your app may have a logout function that brings users back to a login screen. In this case, revert the messaging Web Widget to a pre-login state by calling the logoutUser API.

After a user is logged out, all conversation tags and conversation fields data is cleared. Use the Conversation Fields and Tags API again to apply conversation fields and tags data to a new conversation.