Two kinds of variables
variables
Set in the browser, so a visitor can change them. Use them for page context:
the current page, the selected product, the cart.
signedVariables
A JWT your backend signs, so Typewise trusts the values. Use them for
identity, such as the customer’s email.
Declare every variable you send in Context
Variables. Typewise drops names
you haven’t declared.
Send context when a conversation starts
Passvariables to createClient. Use a function so the SDK reads fresh values
each time a conversation starts, and the first message already carries them:
Update context as the page changes
CallsetVariables when something changes, for example when the visitor picks a
different product option. Before a conversation exists, the SDK holds the values
and applies them to the next one.
string[]
Names not declared in Context Variables. Log this during development: a
non-empty list usually means a typo or a variable you forgot to declare.
string[]
Unsigned values that couldn’t overwrite a value that arrived verified.
Identify signed-in users
PasssignedVariables as a function. The SDK calls it every time it
authenticates, so tokens can stay short-lived:
When the visitor signs in or out
When the visitor signs in, pass a new token. When they sign out, forget the session so the next person on the device starts fresh.Related
- Context Variables: declare variables and use them in actions and lookups
- Chat identity verification: sign the token on your backend
- Storefront concierge example: sends the selected product finish as it changes