Signed-in visitors
If your website has user accounts, pass the signed-in user to the chat. Agents then see which account is writing, marked as verified, and the user gets the same conversation on every device and browser they sign in on.
1. Get the identity secret
Open the site's settings, Signed-in visitors, and copy the Identity secret. Keep it on your server only: anyone with it can make the chat believe they are any of your users.
Make a new secret replaces it. Hashes made with the old one stop working at once.
2. Compute the hash on your server
The hash is the hex HMAC-SHA256 of the user's ID, with the identity secret as the key.
// Node.js
const crypto = require('crypto');
const hash = crypto.createHmac('sha256', process.env.CASDESK_IDENTITY_SECRET).update(String(user.id)).digest('hex');# Python
import hashlib, hmac, os
hash = hmac.new(os.environ["CASDESK_IDENTITY_SECRET"].encode(), str(user.id).encode(), hashlib.sha256).hexdigest()// Go
mac := hmac.New(sha256.New, []byte(os.Getenv("CASDESK_IDENTITY_SECRET")))
mac.Write([]byte(userId))
hash := hex.EncodeToString(mac.Sum(nil))// PHP
$hash = hash_hmac('sha256', (string) $user->id, getenv('CASDESK_IDENTITY_SECRET'));3. Pass the user to the widget
Render the user into the page, before the widget's script:
<script>
window.CasdeskSettings = {
user: { id: "42", username: "ada", name: "Ada Lovelace", email: "ada@example.com", hash: "<the hash>" },
};
</script>
<script src="https://desk.casdoor.com/widget.js" data-site="example-com" async></script>| Field | Meaning |
|---|---|
id | The user's ID on your website. It is what the hash is made of. |
username | The account name, not the display name, so agents know which account it is |
name | The name shown to agents |
email | Where replies the user has not seen are emailed |
hash | The hash from step 2 |
In a single-page app where the user signs in after the page has loaded, call Casdesk.setUser({ id, username, name, email, hash }) instead.
What agents see
In the inbox, the visitor shows with the name, the user name and the user ID on your website, marked Verified by the website. Without a valid hash, the name and email are still shown but are not verified, and the conversation is not shared across devices.
Look and texts
Set the Casdesk chat's color, logo, light or dark theme, position, title, greeting, reply time, welcome message, agent avatar, language and when to ask for the visitor's email.
Conversations
Answer visitors in the Casdesk inbox: open, closed and spam conversations, assigning, searching, what you see about each visitor, and blocking.