Guest User

Untitled

a guest
Jan 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. var client = ZAFClient.init();
  2. // Use the Zendesk App Framework (ZAF) .get(visitor) which returns a promise
  3. // This get returns useful information on the chat visitor, but not full user profile
  4. client.get('visitor').then(function(visitorData) {
  5. console.log('visitor ', visitorData);
  6. // Grab the data for the request for full user data. Either of these ought to work
  7. var name = visitorData.visitor.name;
  8. var email = visitorData.visitor.email;
  9.  
  10. // Build the request JSON
  11. var requestData = {
  12. url: '/api/v2/search.json?query=type:user ' + email,
  13. type: 'GET'
  14. }
  15.  
  16. // Send request using ZAF method .request(), which returns a promise with the response
  17. client.request(requestData).then(function(userData) {
  18. console.log('userData', userData);
  19. // Use the data - fill in your UI
  20. });
  21. });
Add Comment
Please, Sign In to add comment