Recent searches


No recent searches

Zendesk verification

Answered


Posted Jan 09, 2023

I need to display the user's name in the Zendesk chat (for the agents), and I'm using the Zendesk code:

window.zESettings = {
 webWidget: {
   authenticate: {
     chat: {
       jwtFn: function(callback) { 
         fetch('JWT_TOKEN_ENDPOINT').then(function(res) {
            res.text().then(function(jwt) {
             callback(jwt);
            });
          });
        }
      } 
    }
  }
};

and the jwt token is as follows:

var payload = {
  name: '#{customerName}',
  email: '#{customerEmail}',
  iat: #{timestamp},
  external_id: '#{externalId}'
};
var token = jwt.sign(payload, '#{yourSecret}');

The code does not function, and there are no problems, but the user name is not shown. The Zendesk manual is devoid of useful information; has anyone incorporated Zendesk into their app? What am I doing incorrectly? Any assistance and suggestions are much welcomed.


0

1

1 comment

image avatar

Dane

Zendesk Engineering

Hi Callum, 

Here are the references for Classic Chat authentication and Messaging Authentication
 
On my end, I have used this code for the authentication.

Server-side code
require 'jwt'
payload = {:scope => 'user', :externalid => '12137137jXXXXX', :name => 'Gavi', :email => 'gavig@exampl.com'} jwtHeader = {:kid => 'app637192XXXXXXX', :type => 'JWT'}
token = JWT.encode payload, 'gGzxpcAss2wS7YQXsvVNJxMIAn2Akf3Mc0Vy8XXXXXXXXXXXX', 'HS256', jwtHeader
puts token
 
Client-side code: 
 
zE('messenger', 'loginUser', function (callback) {callback('generated_jwt_token');});

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post