Skip to main content
Your server signs a short description of the customer. DeskHoot checks the signature, so your team can trust the name, email and plan they see, and the customer gets their own conversation history on every device.
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

string
required
JSON object
2 ≤ len ≤ 16384
The description of the customer that your server signed, as one JSON string.
string
required
hex
len = 64
The signature of user: HMAC-SHA256 with your signing key.

Fields in user

Leave a field out to keep its current value. Send null to clear it.
string | number
required
unique
1 ≤ len ≤ 256
Your own ID for the customer. The same id always opens the same customer and their conversation history.
string
default:"Customer"
len ≤ 100
The customer’s name, as your team sees it.
string
email
The customer’s email address.
boolean
Whether your product has confirmed that the customer owns email.
string
len ≤ 40
The customer’s phone number.
string
https URL
len ≤ 2048
A link to the customer’s picture.
string
len ≤ 100
The plan the customer is on in your product.
string
len ≤ 256
alias: stripe_customer_id
The customer’s ID in your billing system.
object
The company the customer belongs to.
string | number
ISO 8601
or Unix time
When the customer joined your product.
string
language tag
len ≤ 35
The customer’s language, such as en-GB.
string
IANA name
len ≤ 64
The customer’s time zone, such as Europe/London.

Your own fields

any JSON
name: A-Z a-z 0-9 _
name: len ≤ 40
value ≤ 1024 bytes
max 50 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:
true
The customer is signed in.
{ key, reason }[]
only when fields were dropped
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.
error
raised in the browser
user or hash is missing or has the wrong shape. Nothing was sent.
error
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.
error
user is not a JSON object.
error
id is missing, empty or longer than 256 characters.
error
This customer is blocked in your project.

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.