How it works
- A customer signs in to your portal.
- The widget asks your page for a token. Your page gets a token for the customer from your identity provider or from your backend.
- The platform checks the signature, the issuer, the audience and the age of the token.
- The platform reads the user id and the context parameters from the claims of the token, with the paths that you set.
- The conversation starts. Functions in the flow read the context parameters as internal parameters.
Who can chat
On the page of the widget, click Edit on the Sign-in card. In Who can chat, select a mode:
The two sign-in modes need at least one sign-in provider.
When the customer on the page changes, or signs out, the widget clears the conversation at once. It then starts again as the new customer, as an anonymous visitor (Sign-in optional), or with “Sign in to chat.” (Sign-in required).
Add a sign-in provider
A sign-in provider is an issuer of tokens that the widget trusts, such as your identity provider. A widget can have a maximum of 20 providers. Theiss claim of a token selects the provider.
1
Open the sign-in settings
On the page of the widget, click Edit on the Sign-in card.
2
Add a provider
Click Add a sign-in provider.
3
Fill in the fields
Fill in the fields in the table below.
4
Add the context parameters
Click Add a parameter for each value that the flow needs. See Map claims to context parameters.
5
Save
Select the mode in Who can chat, then click Save.


The Sign-in card with one sign-in provider
Keys
Select how your portal signs its tokens:
Use a JWKS URL when your identity provider publishes one. When a token names a key that the platform does not know, it reads the key set again. Thus a key rotation needs no change here.
Use a Shared secret when your own backend signs a token for the widget. After you save, the secret does not show again. To keep the secret, leave the field empty when you edit the provider. To replace it, type a new secret. If the page shows “This deployment cannot store a shared secret. Use a JWKS URL or a public key.”, use one of the other kinds.
What the token must have
iss, equal to Issuer (iss).aud, equal to Audience (aud), or an array that holds it.expandiat.- The claim that User id path finds. It must be text that is not empty, or a number.
Map claims with SQL/JSON paths
The User id path and each context parameter use a SQL/JSON path. This is the path language of PostgreSQL. The platform runs each path on the claims of the token. Example claims of a token:Outcomes
Each path has one of four outcomes:
An ambiguous or error outcome is a mistake in the path. The visitor cannot correct it. The platform records each one as an error.
Some details about the outcomes:
- In the default
laxmode, a member that is not in the claims gives absent. Instrictmode, it gives error. For example,strict $.customer.idgives error when the claims have nocustomer. - An error inside a filter gives absent, also in
strictmode. For example,strict $.accounts[*] ? (@.number > 1)compares text with a number. PostgreSQL then finds no value, and gives no error. - An error outside a filter gives error. For example,
$.amount.double() ? (@ > 1)gives error whenamountis text. - A user id must be text that is not empty, or a number. Another type makes the sign-in fail.
The check when you save
When you click Save, the platform checks the syntax of each path. PostgreSQL also reads each path. If a path is not correct, the field shows a message. Examples are “This is not a valid SQL/JSON path, such as $.sub.” and “Postgres does not accept this path: …”. This check finds only syntax mistakes. It cannot find a path that finds no value, or two values, in the tokens of your portal. To find those mistakes, use Act as a customer.Map claims to context parameters
A context parameter is a parameter of your tenant that the widget fills from the claims of the token.- In Context parameters, click Add a parameter.
- Select the parameter. To make a new parameter, type its name and select Add ‘name’.
- Type the SQL/JSON path to the value in the claims, such as
$.account.number.
Give the widget a token
Your page gives the widget a token through theidentity option of init. identity is a function with no arguments. It returns a promise of a token for the customer who is signed in now, or null when nobody is signed in.
To use identity, call init yourself, and remove the data-tenant, data-widget-id and data-host attributes from the script tag. See Call DialAI before the script loads.
- Return a new token on each call. The widget keeps no token.
- Return
nullwhen nobody is signed in. - Return in less than 10 seconds. The widget counts no answer as
null. - Keep the token under 32 KiB.
null.
When a customer signs out of your portal, also call DialAI("logout"). Then the next person on the same browser does not see the conversation.
Your backend can sign the token
If your portal has no identity provider that issues JWTs, your backend can sign a short token for the widget:- Your backend checks the portal session of the customer.
- It signs a JWT with HS256 and the shared secret of the provider. Or it signs with its own private key, and you give the public key or a JWKS URL to the provider.
- It puts the verified values in the claims, for example the account number.
- It returns the token to the
identityfunction of your page.
Test the paths with Act as a customer
Act as a customer lets you chat on the Try it card as a signed-in customer, with claims that you type. You do not need a token from your portal. You need theweb-widgets:simulate permission, and the widget must have at least one sign-in provider.
1
Start
On the Try it card, click Act as a customer.
2
Select the provider
In Sign-in provider, select the provider to test.
3
Type the claims
In Claims (JSON), type the claims of a customer’s token. The field starts with a test user at the User id path. The maximum is 16 KiB.
4
Chat
Click Start as this customer. Then open the launcher on the sample site and chat.
- Visitor id — Found, or the reason the sign-in fails, such as “Not in the claims. The sign-in fails.”
- Each context parameter — Set, Not in the claims, or “Does not fit: …” with the schema problem. For an ambiguous path, it shows the values that the path finds. For an error, it shows the PostgreSQL error.


Act as a customer. The paths found the visitor id and set the context parameter.
When a sign-in fails
When the platform refuses a token, the widget gets one of these codes. Your developers can see the code in the network tab of the browser.Best practices
Related
Web Widgets
Create a widget and put it on your site.
Widget appearance
Presets, colours, fonts and the launcher.
Functions and events
Read context parameters in a function.
Building blocks
Make the parameters that the widget fills.