Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var client = ZAFClient.init();
- // Use the Zendesk App Framework (ZAF) .get(visitor) which returns a promise
- // This get returns useful information on the chat visitor, but not full user profile
- client.get('visitor').then(function(visitorData) {
- console.log('visitor ', visitorData);
- // Grab the data for the request for full user data. Either of these ought to work
- var name = visitorData.visitor.name;
- var email = visitorData.visitor.email;
- // Build the request JSON
- var requestData = {
- url: '/api/v2/search.json?query=type:user ' + email,
- type: 'GET'
- }
- // Send request using ZAF method .request(), which returns a promise with the response
- client.request(requestData).then(function(userData) {
- console.log('userData', userData);
- // Use the data - fill in your UI
- });
- });
Add Comment
Please, Sign In to add comment