1
Create a signing key
Create one in Settings › User identity. Keep it on your server; anyone who has it can sign in as any customer.
2
Sign the customer on your server
Build one JSON string about the customer, with any of the fields you can send. Then sign that exact string with HMAC-SHA256 and your key. The result is a 64-character hex string.
3
Pass both to the chat
Put them on the page, above your install code. Send
user as the same string you signed: if a single character differs, the hash no longer matches.Sign in and out without a page reload
In a single-page app, call these when the customer signs in or out of your product.What you pass
The description of the customer that your server signed, as one JSON string.
Fields in user
Leave a field out to keep its current value. Send null to clear it.
Your own ID for the customer. The same
id always opens the same customer and their conversation history.Your own fields
Any other field is saved with the customer as an extra detail. Fields named like a credential or card detail (
password, secret, token, apikey, card, cvv, ssn) are not stored.What you get back
setUser() resolves with:
The fields DeskHoot did not save. Everything else was saved: one bad optional field never blocks the customer.
Errors
setUser() rejects with an error whose code is one of these. When the page sets window.DeskHootSettings, the same code is written to the browser console.
The hash does not match
user under any active signing key. Check that you send the exact string you signed and use a key that has not been revoked.Related
Install with code
Add the chat with one script tag.
Events
Run your code when something happens.
Methods
What
DeskHoot can do.Server API
Create, update and delete customers from your server.