最近搜索


没有最近搜索

Zendesk verification

已回答


已于 2023年1月09日 发布

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 条评论

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


请先登录再写评论。

找不到所需的内容?

新建帖子