Embed the widget
All examples use the base URL: https://api.wiselook.com
Put a Wiselook assessment directly on your own website. This guide is the developer side; what the widget is, who it is for and what your visitors get is on the Widget page. End-to-end the flow is: provision a widget, wire your backend to mint visitor sessions, drop the bundle on your page. A complete runnable example is in step 4.
1. Provision a widget
You need three things from your tenant portal:
- A widget. An admin creates it under the Settings gear → Widgets. A
widget has a name; a channel,
textorvoice, fixed once created (make a new widget to change it); a default language for its visitors; a visitor-ID stability hint, whether theexternal_user_idyour backend will pass is the same for a person across visits (stable), different on every visit (ephemeral) or a best effort (unknown); and its allowed origins: the exact origins of the pages that will embed it, one per line, scheme and host only, e.g.https://careers.example.com. A widget with no allowed origins is inert. No page can mount it. The widget's detail page shows its UUID (WIDGET_ID) and a ready-made embed snippet, and is where origins are added or removed and the widget is disabled or re-enabled. - An API client with the
widget_sessions:writepermission. Copy the client id and secret; the secret is shown exactly once. - An adopted methodology (Settings gear → Methodologies, or
GET /v1/adopted-methodologieswith thetenant_methodologies:readpermission). Copy its UUID (METHODOLOGY_ID). The methodology is chosen per visitor session, not fixed on the widget, so one widget can serve different methodologies to different visitors if your backend decides so.
2. Wire your backend: mint a visitor session
The widget runs in your visitor's browser and can't hold a long-lived secret. Instead, your backend mints a short-lived visitor JWT per session and hands it to the widget. The browser talks to your backend, your backend holds the client secret and calls Wiselook. The secret never reaches the browser.
First, a client-credentials token, as described in Authentication:
TOKEN=$(curl -s -X POST $API_BASE_URL/auth/application/o/token/ \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode "client_id=$CLIENT_ID" \
--data-urlencode "client_secret=$CLIENT_SECRET" \
--data-urlencode 'scope=widget_sessions:write' \
| python3 -c 'import sys,json;print(json.load(sys.stdin)["access_token"])')
Then the visitor session:
curl -s -X POST "$API_BASE_URL/v1/widgets/$WIDGET_ID/sessions" \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"external_user_id": "user-42",
"methodology_id": "<METHODOLOGY_UUID>",
"locale": "es-ES"
}'
{
"session_jwt": "eyJhbGciOiJSUzI1NiIs…",
"expires_at": "2026-09-11T10:37:22Z",
"tenant_end_user_id": "7d3c1f42-…",
"is_new_visitor": true
}
external_user_id is your stable, opaque identifier for the visitor
(your auth system's user id, your CRM's customer id). Do not pass PII
such as emails or names. Wiselook finds or creates the visitor record from it,
so repeat sessions for the same identifier map to the same visitor
record, and is_new_visitor tells you which case you hit.
methodology_id must be one of your adopted methodologies and names
the assessment this session will run. locale is optional: the language
the assessment and the widget itself run in for this visitor, as a BCP 47
tag such as en-US or es-ES. Leave it out and the widget's default
language from step 1 is used. metadata is an optional opaque object
stored on the visitor for your own attribution.
The session_jwt is what the widget mounts with in step 3. Notes:
- The visitor JWT expires after about 15 minutes. Until then it is a
bearer token: whoever holds it can act as that visitor. The widget's
allowed origins stop browser code on another website from using it;
they do not stop a script or a server that has a copy. Treat it like a
session cookie: never log it, serve any page that carries it with
Cache-Control: no-store, and prefermount()(the token stays in a JavaScript closure) over the script-tag form for anything beyond a first try. - Mint one session per visitor per page load. The client-credentials token, on the other hand, is not per-visitor. Cache it until expiry (see the example below).
- Re-minting for the same
external_user_idresumes the same visitor and their assessment. That is how expiry mid-conversation is handled, viaonSessionExpiredin step 3.
3. Embed the bundle
<div id="wiselook-root" style="height: 600px"></div>
<script type="module">
import { mount } from 'https://web.wiselook.com/widget/v1/widget.esm.js';
const { session_jwt } = await fetch('/wiselook/session')
.then((r) => r.json());
mount({
sessionJwt: session_jwt,
target: document.querySelector('#wiselook-root'),
gatewayUrl: 'https://api.wiselook.com',
onSessionExpired: async () => {
const { session_jwt } = await fetch('/wiselook/session')
.then((r) => r.json());
return session_jwt;
},
onAssessmentComplete: (assessmentId) => {
// The candidate has finished talking to Claire. See
// "When the candidate has finished" below.
window.location.assign(`/thanks?assessment=${assessmentId}`);
},
});
</script>
/wiselook/session stands for your own backend endpoint from step 2.
The widget reads its configuration (methodology, channel, branding)
from Wiselook at mount time using the visitor JWT, then runs the
assessment inside a Shadow DOM under target.
onSessionExpired is worth wiring from day one. A real conversation
can outlive the 15-minute JWT. When a call comes back 401, the widget
asks your callback for a fresh JWT, and because your backend re-mints
for the same external_user_id, the assessment resumes instead of
starting over.
The endpoint behind that callback mints a token for a visitor on every
call, so it must know who the visitor is from your own login session or
a cookie you set, never from a parameter the page sends. An endpoint
that accepts ?external_user_id= hands anyone a token for any visitor.
Authenticate and rate-limit it as you would a login.
If your page sets a Content-Security-Policy, allow
script-src https://web.wiselook.com and
connect-src https://api.wiselook.com; voice widgets also connect to a
media host over wss://, which we give you when voice is enabled. The
widget attaches its own styles as a constructed stylesheet, so a strict
style-src without 'unsafe-inline' is fine.
Script-tag alternative
The widget's detail page in the portal shows a declarative snippet that loads the auto-initialising bundle instead:
<div id="wiselook-root"></div>
<script src="https://web.wiselook.com/widget/v1/widget.iife.js"
data-session-jwt="<SESSION_JWT>"
data-target="#wiselook-root"></script>
Your backend renders the freshly minted session_jwt into data-session-jwt
on every page load; an optional data-gateway-url overrides the gateway. The
widget removes the attribute as soon as it has read it, but the token is still
in the HTML your server sent, so serve that page with Cache-Control: no-store.
This form has no onSessionExpired hook. If the visitor JWT expires mid-conversation
the widget tells the visitor the session has expired and asks them to refresh
the page, rather than resuming. Use it for a quick first embed; use mount()
for anything a visitor might spend a while on.
Let visitors come back later
A visitor does not have to finish in one sitting. Their conversation is saved with every message, and the widget can pick it up again on a later visit. Your backend owns this: it remembers which assessment belongs to which of your users, and when that user comes back it tells the widget which assessment to continue. The widget never looks for an unfinished assessment by itself: mounted without an id, it always starts a new one.
Your API client needs the evaluations:read permission as well as
widget_sessions:write, so your backend can check assessments. Request both in
one token: scope=widget_sessions:write evaluations:read.
1. Your page reports the new assessment. The id only exists once the
visitor's first message creates the assessment, so the widget calls
onAssessmentStarted with it. Pass it straight to your backend:
mount({
sessionJwt: session_jwt,
target: document.querySelector('#wiselook-root'),
onAssessmentStarted: (assessmentId) => {
fetch('/wiselook/assessment', { method: 'POST', body: assessmentId });
},
});
2. Your backend checks it and stores it with your user. The request comes
from the browser, so treat the id as a claim, not a fact. Identify the user from
your own login session, never from the request. Then read the assessment with
your API client, as in
Follow one assessment,
and keep it only if its tenant_end_user_id is the visitor you minted this
user's session for. The session mint in step 2 returns that
tenant_end_user_id. Then store the id against your user record.
app.post('/wiselook/assessment', express.text(), async (req, res) => {
const user = req.user; // from your own login session
const assessment = await getAssessment(req.body.trim()); // GET /v1/assessments/{id}
if (!assessment || assessment.tenant_end_user_id !== user.wiselookVisitorId) {
return res.status(404).end();
}
await saveAssessmentForUser(user.id, assessment.id);
res.status(204).end();
});
3. When the user comes back, your backend decides. Before rendering the page, look up the stored id and read the assessment again:
| Status | What your backend does |
|---|---|
in_progress or abandoned (left idle) | Mint the session for the same external_user_id and render the id into the page as evaluationId. The widget shows the conversation so far, reopens an abandoned assessment, and continues. |
scoring or completed | The assessment is over. Show your own next step or the results instead, or forget the id to let the user start again. |
failed or stopped | It cannot continue. Forget the id; the widget starts a new assessment. |
mount({
sessionJwt: session_jwt,
target: document.querySelector('#wiselook-root'),
evaluationId: '<rendered by your backend>',
onAssessmentStarted: reportToBackend,
});
The same external_user_id matters: a session minted for another identifier
is another visitor, who cannot see this assessment. Render evaluationId from
your own records only; never take it from a URL parameter or anything else the
browser sends.
The widget still checks for itself when it mounts. An id it cannot find, or one
belonging to another visitor, starts a new assessment; if the assessment cannot
be loaded at all (a network failure, for example), the widget asks the visitor
to reload the page rather than start over. With debug: true, the widget logs
in the browser console why it started a new assessment instead of resuming.
In the script-tag form, your backend renders the id into data-evaluation-id.
That form has no callbacks, so it cannot report a new assessment; keeping the id
needs mount().
Resuming is for text widgets. A voice widget ignores evaluationId and starts
a new assessment.
4. Save and exit (optional). When your page passes onAssessmentStarted
or onSaveAndExit, the widget shows a Save and exit button above the
message box once the conversation has started. Pressing it tells the visitor
their progress is saved, stops input, and calls onSaveAndExit with the
assessment id, so your page can close a dialog or move the visitor on:
onSaveAndExit: (assessmentId) => {
window.location.assign('/careers');
},
The assessment itself does not change: it stays in progress, ready to resume. Embeds that pass neither callback do not show the button.
Block pasting
Some organisations want answers typed by the visitor, not pasted in from
elsewhere. Pass blockPaste: true to mount(), or add
data-block-paste="true" to the script tag:
mount({ sessionJwt: session_jwt, target, blockPaste: true });
The message box then refuses pasted text and text dragged in, whether by keyboard shortcut, the right-click menu or a phone keyboard's clipboard suggestions, and says under the box that pasting is turned off. Typing works as usual. It is off by default.
Know what this does and does not do. It stops the casual copy from another tab or window. It does not stop a visitor from retyping text they read elsewhere, from a browser extension that types text in, or from someone who changes the page with the browser's developer tools. Nothing about pasting is recorded or sent to Wiselook: the setting only changes what the message box accepts.
Match your site's look
The widget runs in its own sealed-off area of the page, so your stylesheet does not reach inside it. Two supported ways let you style it.
Colours, corners and font. Set any of these CSS variables on the element the widget is mounted in:
| Variable | What it changes | Default |
|---|---|---|
--wiselook-bg | Background | #ffffff |
--wiselook-fg | Text colour | #1a1a1a |
--wiselook-accent | The visitor's messages, the Send button, links and the focus outline | #0f5132 |
--wiselook-muted | Secondary text: status lines and notices | #6b7280 |
--wiselook-border | Borders and dividers | #e5e7eb |
--wiselook-radius | Corner rounding of the frame and messages | 8px |
--wiselook-font | Font family | the visitor's system font |
#wiselook-root {
--wiselook-accent: #1d4ed8;
--wiselook-radius: 12px;
--wiselook-font: "Inter", system-ui, sans-serif;
}
A web font must be loaded by your own page for --wiselook-font to use it.
Individual elements. For anything the variables don't cover, style the
widget's named parts with the CSS ::part() selector:
| Part | Element |
|---|---|
frame | The widget's outer frame |
transcript | The scrolling conversation |
message | Every message |
message-claire | Claire's messages |
message-visitor | The visitor's messages |
error | Error messages shown in the conversation |
status | The status line, for example "Claire is thinking…" |
composer | The area holding the message box and Send button |
input | The message box |
send | The Send button |
paste-notice | The notice shown when a paste is refused |
save-and-exit | The Save and exit button |
saved | The message shown after Save and exit |
complete | The completion card |
#wiselook-root::part(send) {
border-radius: 999px;
text-transform: uppercase;
}
#wiselook-root::part(message-claire) {
background: #f1f5f9;
}
These names are a stable contract on the v1 channel: none is renamed or
removed without a new major version, so styles written against them keep
working. Styling the widget's internal classes or element structure in any
other way is not supported and may break with any release.
Bundle versions
The URLs above load the widget from the v1 channel: the current release
of major version 1, revalidated on every page load, on which nothing breaks
a working embed. A change that would break one ships as v2, and both stay
served for a documented overlap.
Two other shapes exist. https://web.wiselook.com/widget/1.1.0/widget.esm.js
is exactly that release and is cached for a year; use it when you want to
pin or to add an integrity hash. Today only the current release is served at
its exact path, so a pinned embed must move when the next release ships; a
durable archive of every release is planned, and this guide will say when a
pin can be left alone. The bare https://web.wiselook.com/widget/widget.esm.js
is the alias of the current major, kept for embeds created before
versioning; new embeds use the channel.
4. Complete example: a minimal Node backend
Everything above, runnable: a Node 20 + Express server of about 100 lines that caches the access token, mints a visitor session per page load, and serves a page with the widget mounted. No database, no build step.
Create a directory with these four files.
package.json
{
"name": "wiselook-widget-example",
"private": true,
"type": "module",
"scripts": { "start": "node server.js" },
"dependencies": {
"dotenv": "^16.4.5",
"express": "^4.21.2"
},
"engines": { "node": ">=20" }
}
.env with the five values from step 1 (for production, use a
real secret store rather than a file):
API_BASE_URL=https://api.wiselook.com
CLIENT_ID=<your client id>
CLIENT_SECRET=<your client secret>
WIDGET_ID=<your widget UUID>
METHODOLOGY_ID=<your adopted methodology UUID>
The widget's allowed origins must include http://localhost:3000 for
this local run.
server.js
import express from 'express';
import { readFile } from 'node:fs/promises';
import { randomUUID } from 'node:crypto';
import 'dotenv/config';
const { API_BASE_URL, CLIENT_ID, CLIENT_SECRET, WIDGET_ID, METHODOLOGY_ID } =
process.env;
const BASE = API_BASE_URL;
// One client-credentials token serves every visitor mint.
// Cache it; refresh 60s before expiry.
let cachedToken = null;
async function getAccessToken() {
if (cachedToken && Date.now() < cachedToken.expires_at_ms) {
return cachedToken.access_token;
}
const resp = await fetch(`${BASE}/auth/application/o/token/`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
grant_type: 'client_credentials',
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
scope: 'widget_sessions:write',
}),
});
if (!resp.ok) throw new Error(`token mint failed: ${resp.status}`);
const { access_token, expires_in } = await resp.json();
cachedToken = {
access_token,
expires_at_ms: Date.now() + (expires_in - 60) * 1000,
};
return access_token;
}
async function mintVisitorSession(externalUserId) {
const token = await getAccessToken();
const resp = await fetch(`${BASE}/v1/widgets/${WIDGET_ID}/sessions`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
external_user_id: externalUserId,
methodology_id: METHODOLOGY_ID,
}),
});
if (!resp.ok) throw new Error(`session mint failed: ${resp.status}`);
return resp.json();
}
const app = express();
const page = await readFile('./index.html', 'utf8');
const VISITOR_COOKIE = 'acme_visitor';
function readCookie(req, name) {
for (const part of (req.headers.cookie || '').split(';')) {
const [k, ...v] = part.trim().split('=');
if (k === name) return decodeURIComponent(v.join('='));
}
return '';
}
app.get('/', async (req, res) => {
// Demo visitor: a fresh id per page load. In production, use your
// real user identifier here (opaque id, never PII).
const externalUserId = `demo-${randomUUID().slice(0, 8)}`;
const session = await mintVisitorSession(externalUserId);
// Remember who this visitor is in a cookie only this server reads;
// the re-mint endpoint below takes the id from here, never from the
// request. In production this is your login session.
res.cookie(VISITOR_COOKIE, externalUserId, {
httpOnly: true, sameSite: 'lax', secure: req.secure,
});
// The page carries a bearer token: no caching anywhere.
res.set('Cache-Control', 'no-store');
res.type('html').send(
page
.replaceAll('{{SESSION_JWT}}', session.session_jwt)
.replaceAll('{{API_BASE_URL}}', API_BASE_URL),
);
});
// Re-mint for the widget's onSessionExpired callback. Same
// external_user_id resolves to the same visitor, so the assessment
// resumes. Each call mints a token for that visitor: identify them
// from your own session, and rate-limit this like a login.
app.get('/session', async (req, res) => {
const externalUserId = readCookie(req, VISITOR_COOKIE);
if (!externalUserId) return res.status(401).end();
const session = await mintVisitorSession(externalUserId);
res.set('Cache-Control', 'no-store');
res.json({ session_jwt: session.session_jwt });
});
app.listen(3000, () => console.log('http://localhost:3000'));
index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Acme careers assessment</title>
<style>
body { font-family: system-ui, sans-serif; max-width: 760px;
margin: 2rem auto; padding: 0 1rem; }
#wiselook-root { height: 600px; border: 1px solid #e5e7eb;
border-radius: 8px; overflow: hidden; }
</style>
</head>
<body>
<h1>Welcome to Acme careers</h1>
<div id="wiselook-root"></div>
<script type="module">
import { mount } from 'https://web.wiselook.com/widget/v1/widget.esm.js';
mount({
sessionJwt: '{{SESSION_JWT}}',
target: document.querySelector('#wiselook-root'),
gatewayUrl: '{{API_BASE_URL}}',
onSessionExpired: async () => {
// The server knows the visitor from its cookie; the page never
// names one.
const res = await fetch('/session');
if (!res.ok) throw new Error(`re-mint failed: ${res.status}`);
const { session_jwt } = await res.json();
return session_jwt;
},
});
</script>
</body>
</html>
Run it:
npm install
npm start
Open http://localhost:3000: the widget mounts and the assessment
greeting appears. The client secret stayed on the server; the browser
only ever saw the short-lived visitor JWT.
The same flow works in any language that can speak HTTPS. The token call is a standard OAuth2 client-credentials grant, and the session mint is a plain POST with a Bearer token.
When the candidate has finished
There are two moments, with a different signal for each.
The conversation is over. The widget shows its completion card and, in
the mount() form, calls your onAssessmentComplete option once with the
assessment id. Use it to send the candidate on to your own next page, or to
tell your backend that this assessment is now worth watching. The script-tag
form has no such hook: with it, the candidate sees the completion card and
your backend learns about the end of the conversation only from the API.
The results are ready. Scoring runs in the background after the
conversation, so the assessment is not finished when the widget says so. Its
status moves from in_progress to scoring when the conversation ends,
and to completed when the score is ready; the score stays null until then.
There is no callback or webhook for this moment. Read the assessment with an
API client as described in
Retrieve assessment results:
either follow one assessment until its status is final, or list what
completed since your last sync, which is the better fit for a backend that
handles many candidates.
5. What the widget does
- Text channel streams responses over SSE, rendering token-by-token.
- Voice channel opens a WebRTC session. The visitor talks with Claire, Wiselook's AI assessment agent, by voice.
When the conversation ends, the visitor sees a completion state and scoring runs in the background. Results are available through your tenant portal and the API; see When the candidate has finished.
Troubleshooting
| Symptom | Likely cause |
|---|---|
401 invalid_client minting the token | Wrong client id or secret, or a stray newline or space pasted into the secret value. |
401 minting the session | Token expired, or the client lacks the widget_sessions:write permission. |
422 minting the session | Missing methodology_id, or an id that is not one of your adopted methodologies. |
origin_not_allowed in the browser console | The embedding page's origin is not in the widget's allowed-origins list (exact match, scheme and port included). |
| Widget mounts but won't start | Visitor JWT expired before mount; mint a fresh one per page load. |
404 Widget not found | Wrong WIDGET_ID, or the widget was disabled. |