Accessing User Data in HelpDocs

Jake Peters Updated by Jake Peters

You can pass user data to HelpDocs in either JWT auth or Shared Password as SSO. If you haven't already passed the data, check out the relevant article for more instructions šŸ‘€

Accessing Data

In your knowledge base you can access params from user_data by reading the hd_user_data cookie and decoding the JSON body.

Let's assume you've passed us this data for a user through JWT auth or Shared Password as SSO:

{
"name": "Jake",
"user_id": 1
}

Then you can use a snippet a little like this one to access the data:

var user_data = {};
try {
user_data = JSON.parse(Cookies.get('hd_user_data'));
} catch (e) {
console.log('Error parsing user data');
}
console.log(user_data.name); // "Jake"
console.log(user_data.user_id); // 1

You can include the above snippet in places like your live chat integration to identify your users, or in Settings > Code > Scripts.

What did you think of this doc?

Restricting Your Docs to Logged In Users

Shared Password Protection