init applied first whatever position it was queued
in.
Commands
Commands never return a value — a queued call has nothing to return yet. Read state
through events instead.
Events
ready fires once per page load. Subscribe before boot — from the queue stub — or you may
subscribe after it has already fired.
Identity verification
If your visitors sign in, tell us who they are. Their conversations then attach to that customer, and their history follows them from laptop to phone. Do it with a signature. Without one,identify() is a browser asserting an identity, and
anyone who can open developer tools can assert somebody else’s.
1
Get the identity secret
Settings → Channels → Website chat → Security. It is shown once, on creation, and once
again each time you rotate it. It starts with
wc_sec_.2
Sign the user id on your server
userHash is an HMAC-SHA256 of the user id — the exact string you pass as userId —
keyed with the secret, hex-encoded.3
Pass it to the widget
Render the hash into the page for the signed-in user, and identify once after boot:
4
Require it
Once your site is signing, turn on Require a valid signature under Security. Until
you do, unsigned claims are accepted but stored as unverified — usable context for an
agent, never trusted for identity.
What “verified” changes
The third row is the point. Reuniting a browser with an existing identified visitor is
what would let “identify as somebody else” become an account takeover, so it happens only
on a signature we can check.
Attributes
attributes is free-form context an agent sees beside the conversation: plan, cart value,
signup date. Scalars only — strings (truncated at 500 characters), numbers and booleans.
Up to 30 keys. Nested objects are dropped.
Don’t put anything in there you wouldn’t want an agent to read.
Signing visitors out
Events for automations
webchat.event trigger for your automations. It is not stored: what makes an
event useful is an automation acting on it, and a table of every page view on every
customer’s site would be a cost with no reader.
Errors you might see
A conversation id that isn’t this visitor’s answers
404, not 403. That is deliberate:
a 403 would confirm the conversation exists, which is exactly what someone guessing ids
wants to learn.
