Zendesk authentication

I need to display user’s name in the in the zendesk chat ( for the agents), I’m using the code provided by zendesk:

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

and jwt token is:

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

The code doesn’t work, I don’t get errors but user name is not visible. Zendesk documentation doesn’t provide any valuable information, has anyone integrated Zendesk in their app? What am I doing wrong? any help and suggestion is greatly appreciated.