Web SDK
How Rendel behaves on a website — the tag, version pinning, signed-in visitors, allowed domains, dark mode, CSP, actions, screens, goals and events.
The web SDK is one JavaScript file with no dependencies. It does not care what your site is built with, and it speaks the same protocol as the Flutter SDK: the same components, the same actions from the console, the same persona. One app in the console can serve your mobile app and your website with the same key.
Set up with AI adds it: your coding agent puts the tag on every page, wires sign-in, registers screens and fills in the console. This page is what that leaves in your site and how the SDK behaves, for when you change it later. Before the app is live, which the setup does by itself when its checks pass, the live key works as the test key does and shows the draft.
To change any of it, start from a task: each opens with the prompt for your coding agent. This page is what that prompt relies on.
The tag
<!-- Inside <head>, on every page, with the live key from the start: it works as
the test key until you go live, so nothing here changes then.
data-app-key: your app's key — Rendel console → Settings → Keys & environments → Copy.
data-languages: the language for a message that does not say which — "en"
English, "en,tr" English or Turkish by the browser's. A visitor writing in
another language is answered in theirs. Leave it out to follow the visitor. -->
<script
src="https://rendel.ai/sdk/web/0.91.0/rendel.js"
integrity="sha384-ChzojTsCfPdc7ZFAy/NHF6dPiTXpqOh8xQxh6MsCn3jwXK2MRaDkjSkiL44s4Lx+"
crossorigin="anonymous"
data-app-key="rd_pk_live_…"
data-languages="en"
></script>It sits inside <head> on every page; in Next.js it is a <Script> with
strategy="beforeInteractive" in the root layout. The tag also reads
data-locale and data-api-base-url, data-launcher="false" hides the
corner button that opens Rendel, and data-read-aloud="false" keeps answers
from being read aloud.
Load it without async or defer. With either, a script of yours that calls
Rendel before the file has run throws Rendel is not defined, and the
identify or registerRoute in it never happens, while the button still shows
and answers as if nobody were signed in. A page that must load the tag late
makes those calls in the tag's onload.
Pinning
The version is in the address. 0.91.0 stays 0.91.0 after the next release
ships, so your site changes only when you change the number. The
changelog says what each version brings.
From 0.78.0 the tag carries the file's fingerprint, integrity with
crossorigin="anonymous": if the file at that address ever changed, the
browser would not run it, and rendel.js checks rendel-ui.mjs against the
fingerprint built into it the same way. A released version never changes, and
every version's fingerprints are in
integrity.json.
From 0.64.0 the panel is a second file, rendel-ui.mjs, which rendel.js
loads from its own folder while your page starts, so your page paints without
waiting for it. If you serve the SDK yourself, copy both files.
Who is signed in
// Right after your sign-in succeeds. traits.email is where Rendel's
// emails to this person go; leave traits out if you hold no address.
Rendel.identify({ userId: user.id, traits: { email: user.email } });
// On every page: the signed-in person's current token, or null, so
// Rendel can reach your API as them — no API key.
Rendel.setUserToken(() => getAccessToken());
// When the user signs out:
Rendel.reset();setUserToken is how Rendel answers from your own API — "my order", "my
routine" — as the person asking, with no API key to issue: in the console,
those endpoints are set to the signed-in user's token. The function is asked
before every question, so it returns the current token (refreshed there if it
has run out), or null when nobody is signed in. It goes on to your endpoints
as Authorization: Bearer, is never stored, and each person reaches only what
their own token opens. It is called on every page, since a function cannot be
remembered across loads.
An endpoint that changes something — "book me in on Tuesday" — is asked on a confirmation card first. Once the person confirms, Rendel makes the call as them and answers with what happened; there is no handler to write on the page.
userId is the id your own backend knows the person by — the same one your
mobile app passes, so a person has one history across both. The SDK remembers
them across page loads and visits, so a returning visitor needs no second call.
traits ({ plan: "pro" }) carries anything Rendel should know about
them, and userHmac is needed when
identity verification is on.
Without these, every visitor is anonymous and their conversations belong to the browser. That is the right default for a site with no sign-in.
The conversation follows the visitor from page to page within the tab: a link to another page of your site does not start it over.
Allowed domains
The test key works on localhost and 127.0.0.1, on any port, straight away.
Anywhere else, a deployed preview included, the site's domain must be listed in the console under
Settings › Security › Allowed domains, for the test key and the live key alike. A key in a web page can be read by anyone who opens
its source; the list is what stops it working on their site. Until the domain
is listed, either key answers that site with origin_not_allowed, the button does not show there, and Home names the site with Allow it.
When Set up with AI finishes on a website and nothing is listed yet, it lists the domains the site's code names, or else the one its public pages are on.
musteri.com means https://musteri.com. www.musteri.com is a separate
entry, and *.musteri.com covers every subdomain. Your mobile apps send no
domain and are not affected by the list.
Dark mode
With the default themeMode: "system", the panel follows your page first and
the browser second: a data-theme="light" or data-theme="dark" on <html>
(or else <body>), which is what most sites' own appearance switches set, and
without one the visitor's prefers-color-scheme. Both are watched, so a switch
repaints the panel. "light" or "dark" is final, and
Rendel.setThemeMode(...) changes the mode while the page runs. The dark
colours are darkTheme, or derived from theme when it is left out; see
Map your brand to the catalog.
Permissions
Nothing to add to any file. The "+" offers Photos and Files, which open the browser's own file picker (pictures; PDFs and text files), and Camera, which the browser asks the visitor for the first time it is used. The microphone uses the browser's speech recognition — the browser asks the visitor for the microphone the first time it is pressed. It is clicked to speak: what the visitor says is written in the middle of the panel as they say it, and it is sent when they pause, or at once with a second click on the microphone. A click anywhere else, or Escape, lets it go unsent. The microphone stays where it is, in the corner unless voice first makes it the wide pill (from 0.82.0; before, it was held).
- The microphone needs https (
localhostcounts). Firefox has no speech recognition, so it is not shown there; everything else works. - Inside an
<iframe>, the frame needsallow="microphone; camera". - If your site sends a Content-Security-Policy, add these sources to its directives:
script-src https://rendel.ai;
connect-src https://api.rendel.ai https://tiles.openfreemap.org;
img-src https: blob:;
worker-src blob:;tiles.openfreemap.org and worker-src blob: are for the map block (0.20.0
and later). The map engine loads from rendel.ai beside rendel.js, and because a
browser will not start a worker from another origin, it runs its worker from a
blob: URL. If your policy also sets style-src or default-src, add
https://rendel.ai there for the map's stylesheet. blob: in img-src is for
photo previews and your logo.
Actions
Actions you connect in the console run on our servers and work on the website with no code. An action that should run in the page, as the signed-in visitor, is registered the way the Flutter SDK registers one:
Rendel.registerAction({
name: "get_order_status",
description: "Fetch the delivery status of an order",
params: {
type: "object",
properties: { order_id: { type: "string" } },
required: ["order_id"],
},
risk: "read",
handler: async ({ order_id }) => {
const response = await fetch(`/api/orders/${order_id}`);
return response.json();
},
});params is JSON Schema. Return what Rendel should know, or throw to say it
failed; keep the result under 32 KB (from 0.82.0; a larger one goes as its start, marked as cut). A handler has timeoutMs (15000 by
default). Its second argument is the invocation, { id, name, params, risk }:
the id is the same when a turn is retried, so it is the natural idempotency
key. sandboxResult is returned instead of running the handler while a test
key is in use. write and destructive actions get the same server-built
confirmation card as on a phone, and confirmTemplate words it.
A parameter declared { type: "string", format: "attachment" } (from 0.91.0)
takes a file the visitor attached in the conversation, and the card shows it.
The handler is given its id; await Rendel.attachment(id) returns the File,
or null when nobody attached one.
More fields shape that card:
editable: ["quantity"]names the parameters the visitor may change on the card before confirming. The server checks a changed value as it checks the model's and redraws the card with it. Use it for a quantity, a note, or one of a few choices; never for an id or an amount your app computes. At most twelve. See Values the user can change on the card.undoable: trueis for adestructiveaction the visitor can still take back afterwards, such as an order that can be cancelled while it is packed: its card does not say "This cannot be undone".- A parameter's
titlelabels its row on the card, andtitlesgives that label per language ({ tr: "Adet" }), picked likeconfirmTemplates. See Locales. typeToConfirm: "app_name"names a parameter the visitor types back before the confirm button works ("type the app's name to delete it"). Never one ineditable; the server checks it again.fullText: { param: "body" }shows a long string parameter whole, as a preview and then Read all, and the confirm button works once all of it has been opened. Withcurrent: truethe card also shows the lines that change, from the textRendel.setCardSource("update_terms", async (params) => …)returns for the action;nullremoves it.confirmLabel(up to 32 characters) andconfirmLabels({ tr: "Uygulamayı sil" }) word the confirm button, picked likeconfirmTemplates.undo: { action: "remove_from_cart" }names the action that takes this one back. Awritethat names one runs with no card: the answer opens with a line saying what it did, and an Undo that works for ten minutes. Parameters the two share by name pass through;paramsfills the others from the call ("{params.product_id}") or from what it returned ("{result.line.id}").confirm: "always"keeps the card anyway; adestructiveaction always asks.
Rendel.registerAction({
name: "add_to_cart",
description: "Add a product to the cart",
params: {
type: "object",
properties: {
product_id: { type: "string" },
quantity: { type: "integer", minimum: 1, maximum: 10, title: "Quantity", titles: { tr: "Adet" } },
},
required: ["product_id", "quantity"],
},
risk: "write",
confirmTemplate: "Add {quantity} to your cart?",
editable: ["quantity"],
handler: async (params) => cart.add(params),
});Screens
A screen of your site Rendel may offer on a
screens card:
Rendel.registerRoute({
name: "order_detail",
title: "My orders › Order",
description: "One order: its items, delivery and payment.",
params: { order_id: { type: "string", required: true, fromActions: true } },
open: ({ order_id }) => router.push(`/orders/${order_id}`),
});A tap shrinks the panel into a bubble and calls open. The bubble brings the
panel back. bubbleOffset (px; 104 on a phone-wide page, 24 otherwise) keeps
the bubble above your own bottom bar.
From 0.15.0. A param marked fromActions must equal a value one of your
actions returned in this conversation. Names are snake_case; a title is 1–60
characters, a description up to 300; up to 8 params and 50 routes.
Screen views
Rendel answers about the page in front of the visitor: "what does this
mean?" on a checkout page is a question about that checkout. Analytics ›
Explore › Events shows which pages are seen most and what people asked on each. There is
nothing to add: from init, every page a visitor sees is sent as a screen
view, from every browser, whether or not they open Rendel.
- The name is the path with its ids replaced:
/orders/8812becomes/orders/:id. Digits, UUIDs, long hex strings, long tokens and email addresses become:id; the query and the hash are dropped (a hash router's#/pathis read as the path). A page Rendel opened from a screen you registered withregisterRouteis called by that screen'stitle. - The same screen twice in a row is sent once. Views go in batches: every 15 seconds, when the page is hidden, or sooner when many add up.
- Each question carries the screen it was asked on, and Rendel also reads the few screens before it.
- A screen view is the screen's name only: never a field or what the page shows. Taps are counted on their own, without what was typed; see Taps. How long it is kept is under Storage and retention.
Where the path says too little, as in a single-page app that never changes it, or a step inside one page, name the screen yourself:
Rendel.setScreen("Checkout › Payment");
// Back to the name the SDK reads from the address:
Rendel.setScreen(null);The name holds until the next navigation or the next call, and it is safe to
set before init.
Events
Count the steps that matter in your app, and Analytics builds funnels from them: where people drop before buying, and whether those who asked Rendel went further.
Rendel.track("add_to_cart", { product_id: "sku_812", price: 549.9, in_stock: true });
Rendel.track("checkout_started", { items: 3 });- The name is lowercase, a letter first, then letters, digits or
_, up to 40 characters. - Properties are one flat object: up to 20 keys, named like event names, each
value a string of up to 255 characters, a finite number, a boolean or
null. Nothing nested. A longer string is cut; a key or value that does not fit is dropped and the event is kept. - A string that looks personal (an email address, a phone number, a card
number, an IBAN, an 11-digit national id or any run of four or more digits)
is replaced with
[masked]in the browser, and again on the server. Send ids you would not mind seeing in a report, never a customer's details. tracknever throws, and events go in the same batches as screen views.
Super properties describe the whole visit, such as the visitor's plan:
Rendel.register({ plan: "pro", ab_group: "b" });
Rendel.unregister("ab_group");Up to 20 keys, with the same rules as event properties. They are kept in the browser and sent once per session, not on every event, so a change in the middle of a session applies to that whole session.
Goals
Tell Rendel what counts as a success on your site, and the console's Value tab shows how often it happens, and how often after a conversation with Rendel.
// Where sign-up succeeds:
Rendel.track("signup");
// A success with a value:
Rendel.track("booking", { value: 120, currency: "TRY" });Every track call is an event. A name counts as a goal once it is
marked as one in the console; every name your site already sent as a goal is
marked for you. value is optional, 0 or more, and needs a three-letter
currency. "purchase" works as it did; see Follow-ups.
A goal sent from the page is shown as reported by the app, because anyone
can call it from the browser's console. For a count nobody can forge, send
the same goal from your server, signed with your identity secret:
POST /v1/goals.
Taps
See which buttons people press on the way to buying or leaving, with no code
to add: from init, the SDK counts every tap on a button, link, tab, menu
item, checkbox or switch, and on anything with role="button" or a pointer
cursor.
- What a tap records: the screen it was on, the kind of control, its
caption (
data-rendel-name, elsearia-label, else a button's or link's own text) cut to 50 characters and masked as above, and a stable locator (data-rendel-name,data-testid, a hand-writtenid, else a short CSS path). An internal link adds its target path, cleaned like a screen name; an external one adds its host only. Three clicks on one element within a second are marked as a rage tap. - Never recorded: what is typed into a field, a
select's chosen option, editable text, where on the page the tap was, keystrokes, the clipboard, scrolling or a picture of the page. A field gives only its type andname. Taps inside Rendel's own panel are not counted.
Three attributes tune it, on any element:
<!-- A stable name, the same in every language: -->
<button data-rendel-name="add_to_cart">Sepete ekle</button>
<!-- Counted, with no caption: for balances, messages, names -->
<section data-rendel-mask>…</section>
<!-- Not counted at all -->
<div data-rendel-ignore>…</div>In the console, Settings › Data & privacy › What Rendel records turns taps on, keeps them without captions, or turns them off; keeps the taps of all devices, half or a tenth (chosen by device, so a person's path stays whole); and lists screens or CSS selectors where taps keep no caption. A change reaches each browser the next time the page loads. An app with strict masking on records taps without captions.
Analytics consent
When your site asks visitors whether they accept analytics, pass their answer to Rendel:
// Declined:
Rendel.setAnalyticsEnabled(false);
// Accepted later:
Rendel.setAnalyticsEnabled(true);With Wait for the user's consent on, taps and screen views start only after Rendel.setAnalyticsConsent(true), and false stops them. Call it on every page. See Wait for consent.
Off stops screen views, taps, events and sessions from that browser, and the choice is kept there. Rendel itself keeps answering. Your site owns the consent banner; Rendel does not show one.
Preference memory
Rendel keeps a preference a visitor states once, such as "always lactose-free", or one it notices more than once, and uses it in later answers.
See what it looks like to your customers and your team: Memory.
- Every save is shown under the answer as a chip, with Undo. Updated and forgotten preferences, and an answer based on one, are shown there too.
- A card value or form field filled in from a preference says "From your preferences".
- "What I remember for you" lists each preference with Forget, and Forget
all. It opens from those chips, or from your own settings or privacy page
with
Rendel.openMemory(). - The same list shows what answers read about the visitor beyond those
preferences: the
traitsyou pass toidentifyand the facts your backend keeps withPOST /v1/people/:id/notes, marked "From the app" and without Forget, and what Rendel noticed without naming it, under "Other", with Forget. Pass only traits you would show the visitor. - For a visitor who is not signed in, preferences are kept for that browser;
they move to the account when
identifyis called. - Turn it off in the console under Settings › Data & privacy › Preference memory. Off, nothing new is kept, and the list says the app keeps no preferences.
Turn on identity verification and pass userHmac
to identify. Until then, a user's preferences are read only in a browser that
has been that user before, so someone who knows their id cannot open them
elsewhere, and a signed-in visitor's list shows only what that browser kept
while they were signed out. The Undo under a save works
either way, in the browser that saved it.
Follow-ups
When something a visitor asked for has news (a price that dropped, an answer
that arrived, a date coming up), Rendel tells them. Whichever way a message
went, by push, by email or in the app, it waits as a card at the top of the
panel when the visitor opens it: up to three from the last seven days that
they have not opened or put away, and a tap opens the conversation about it
(0.38.7). A message sent "In the app" also shows while the panel is closed,
once a session: a small popup by the launcher, or a banner across the top of
the page, as the send chose. A page with its own launcher (launcher: false)
gets the banner and the cards, not the popup. The words are the server's,
already in the visitor's language.
The browser's time zone and language are sent with it, so a follow-up keeps to
quiet hours and speaks the visitor's language.
// When the visitor buys: credited to the follow-up they last opened.
Rendel.track("purchase", { value: 549.9, currency: "TRY", items: [{ id: "sku-42", quantity: 1 }] });value is 0 or more and currency a three-letter code; items is optional,
at most 20. A malformed call is logged, never thrown. Rendel.reset() drops a
follow-up meant for whoever was signed in, on the page and, from 0.49.0, on the server.
Your team
When someone needs a person, your team answers inside your site. With Support on, "I want to talk to a person" is enough; other wordings get the assistant's offer of your team. For your own "Contact us", open the page yourself; it works while the assistant is paused too. While Support is off for this app, it opens only the conversation the person already has, so they read why it closed and how to reach you, and starts none. The page opens at once, and the conversation starts with the person's first message, so nobody who only looks leaves an empty one in your team's queue.
contactUs.addEventListener("click", () => Rendel.openSupport());
Rendel.on("unread", (count) => {
badge.textContent = count || "";
});
Rendel.on("support", ({ open, unread }) => {
askButton.dataset.dot = open || unread > 0 ? "on" : "";
});Rendel.supportUnread is the number of the team's lines this person has not read, and unread fires when it changes. The launcher shows it on itself. support fires with { open, unread } when a conversation with your team opens or is sorted, or its unread lines change, so your own Ask button can carry a dot while one is open and the count while their reply waits; Rendel.supportOpen says the same at any time. While the page is in view and your app has Support on, the SDK checks for the team's reply every half minute and shows it in the page: a banner across the top while Rendel is closed, a line at the top while it is open. A check that fails changes nothing; the next one catches up. From 0.72.0 the same check brings any read of their account your team asked for, so it runs wherever they are on your site, and with setUserToken it tells Support whether the person is signed in, so your team is offered only the changes that can run as them.
Also from 0.72.0, the page says when your team is back on the person's own clock. While your team is answering them, someone without an email address keeps writing, with the request for one above the message box. A conversation closed because you switched Support off says so, with your contact channels to tap and no message box. It stays in Recent while Support is off, so the person sees the closing line and your channels the next time they open it. Once you switch Support on again, they can write in it again like any sorted conversation. If too many conversations were started from one device or network in a short time, the page says so and the person's message waits to be sent again.
Options
The data attributes cover the common case. For the rest, leave data-app-key
off the tag and call init yourself:
Rendel.init({
appKey: "rd_pk_test_…",
languages: ["tr"],
assistantName: "Pati",
suggestions: ["Milo bugün nasıl?", "Aşı takvimini göster"],
launcher: false, // your own button: Rendel.open()
});| Option | |
|---|---|
languages, locale | What it answers in; locale is your site's language picker. The SDK's own words are in locale when you set it; otherwise in the browser's language when your assistant answers in it (languages, else the ones picked under Persona), else in English when it answers in English, else in its first language. The panel's lang attribute is that language, then the conversation's once an answer says it, so a screen reader reads each answer in its own voice. |
assistantName, launcherLabel, suggestions, emptyStateTitle, emptyStateBody, composerHint | The words on screen. |
suggestionCards, groundLight | The opening's own look. suggestionCards gives a suggestion its own title and line, by its words: { title, line }, the title at most 40 characters, the line at most 60; a suggestion without a card shows its own words. The suggestions are a list under the greeting, one card with a row for each and an arrow at the end. An image is accepted and no longer drawn: the row of picture cards over the message box went in 0.89.0. groundLight is your app's two colours, left then right (["#D9A43A", "#1E3B2F"]), drawn as a pale light from either side of the panel; without it, your accent from both sides. Appearance › Assistant screen › Behind the assistant sets its colours and strength too, and wins over this (0.81.0). |
strings | Your own words for the SDK's chrome, by key (confirm, goBack, irreversible, composerHint, launcher, …), laid over the shipped set for the answer language; a key you leave out keeps the shipped translation. rendel.d.ts exports the Strings interface, so a misspelt key is a type error. |
attachIcon, voiceIcon, sendIcon | The composer's three glyphs. "off" removes attach or voice. |
voiceFirst | What the composer leads with at rest. Left out or false, the place to type, with a "+" before it and the microphone a round button after it (the default from 0.71.0). true, the microphone: a wide button in the middle, held to speak, with a "+" on one side and a keyboard on the other that opens the box to type. Usually chosen in Appearance › Message box › How people ask. |
launcherStyle, launcherIcon, launcherDraggable | The corner button: "label" (the default) shows its icon and its word, "icon" a round button with the icon alone that still says the word to a screen reader. The icon is one of 20 ("sparkle" by default; rendel.d.ts lists them), or your own, uploaded in the console's Appearance. true lets visitors drag it: it settles on the nearer side and stays there in that browser. All three can be published from Appearance. |
launcherFill, launcherRing, launcherRingWidth, launcherGlow, launcherSize | The corner button's own look, each optional: a gradient in place of the accent ({ colors, direction }, drawn only where the icon or word reads on it), a ring round it in a colour (launcherRingWidth 1–8, 3 by default), a glow in a colour in place of its shadow, and the round button's size, 40–72 (50 by default). All can be published from Appearance (0.55.0). |
launcherLight, launcherIconSize, launcherGlowStrength | A light over the button's fill and under its icon ({ color, x, y, strength, radius }: strongest at x, y, 0–1 across and down; strength 0.7 and radius 0.6 of the width by default), the icon's size in px (12–48), and how strong the glow is (0.1–1, 0.45 by default). All can be published from Appearance (0.56.0). |
feedback | true shows "Helpful?" with a thumb up and down under each answer, counted in Analytics. Usually switched on from Appearance. |
theme | surface, onSurface, accent, onAccent and the rest of the console's appearance roles. |
themeMode, darkTheme | system (the default), light or dark, and the colours for dark. See Dark mode. |
ground | What the panel is drawn on instead of its plain surface: CSS colours and gradients only, such as your page's own background lights over a colour. Change it while the page runs with Rendel.setGround(...), or null for the plain surface. |
readAloud | Answers read aloud in a natural voice, in the answer's language: every answer's opening is read by itself as it arrives (the Voice replies switch in the header turns that off). On by default; false keeps the site silent. Only in a tab someone is looking at. Nothing is read until the app's console turns voice on (Assistant › Voice). |
launcher | false hides the corner button. Open it with Rendel.open(), close() or toggle(). Then your button is the only way in, always: when a screen of your site opens from an answer, the panel steps aside without a bubble and your button brings it back as it was. With the corner button on, add no button of your own. To leave it off some routes of a single-page site, keep it on and call Rendel.setLauncher(false) on those routes and Rendel.setLauncher(true) on the others (0.49.2); it hides only while Rendel is closed. A site of separate pages puts data-launcher="false" on the tags of the pages without it. |
enabled | false turns Rendel off and wins over anything published. |
remoteConfig | false ignores what is published in the console. |
actions | The same as registerAction, all at once. |
userToken | The same as Rendel.setUserToken. |
onOpenUrl | Route a card's link yourself instead of opening a new tab. |
bubbleOffset | px above the bottom edge for the bubble while a screen Rendel opened is showing: 104 on a phone-wide page, 24 otherwise. |
apiBaseUrl, requestTimeoutMs, streamIdleTimeoutMs | Where it calls, how long a request may take (ms, default 30000; the config read on page load gives up after 8000), and how long a turn may go silent (ms, default 45000). |
onLog | Receives the SDK's warnings instead of the browser console. See Log codes. |
Appearance and the opening surface published from the console override these, on the website and the app alike, without a release.
Rendel.on("opened" | "closed" | "messageSent" | "actionExecuted", fn)
subscribes to what happens. Rendel.on("changed", fn) says what Rendel changed
in your site's own data, so the page can refresh what it holds of it: fn
gets { action, risk, params, undone }, once for every write the server
carried out for the person and once more, with undone true, when they take
one back; an action the page runs itself fires actionExecuted instead.
Rendel.on("changed", (change) => {
if (change.action.includes("cart")) cartStore.refresh();
});Rendel.available is whether a new conversation can start now. It is false
while new conversations are paused for your organization (its generated screens
for the month used up, its spending cap reached, an app's questions per day used) or while
Rendel's API cannot be reached. It turns true again by itself, checked every
few minutes; Rendel.on("availabilityChanged", fn) tells you when it changes.
The corner button stays on screen either way (0.49.3): a question asked while
paused is answered with a calm sentence, and one asked during an outage shows
a retry.
Rendel.addContextProvider(key, fn) sends what the page knows with each
question: fn is called right before the question goes, has 300 ms to answer,
and its value goes under key. One that is slow or throws costs only its own
context (context_provider_timeout, context_provider_failed), never the
turn. Rendel treats what it returns as data, never as instructions.
Rendel.addContextProvider("cart", () => ({ items: cart.count, total: cart.total }));Rendel.deviceId is the anonymous id to quote
in a support ticket. Rendel.isOpen, Rendel.isInitialized and
Rendel.version report state. Rendel.refreshConfig() re-reads the published
appearance. Rendel.pair(code) pairs a test browser with the console
(Pair a test app). On a test key, the same
code sent as a message in the panel pairs it too, with no code of yours (0.57.0).
Log codes
What onLog receives, in record.code. The code is stable and safe to switch
on; message is for humans and may be reworded.
code | When |
|---|---|
already_initialized | init was called again with a different appKey; the first one stands. |
app_suspended | Debug: the app is suspended in the console, so Rendel is hidden. |
unavailable | New conversations are paused, or the API cannot be reached, for the reason in the message. The corner button stays; see Rendel.available. |
invalid_action / invalid_route | A registered action or route was malformed and skipped; the message names the field. |
invalid_user | identify needs a userId of 1 to 128 characters that is the user's own id; one like "undefined" or "null" signs the person out instead. |
identify_refused | The server refused identify: a userHmac that does not match, an id that is no id, or a key it does not know. Or it bound nobody (identify_unsigned): an id without userHmac on a browser that has not been that person (another key in the same browser counts as another), whose questions then count as an anonymous visitor's. Logged once with the server's code and reason, and not tried again. |
ui_unavailable | The panel's file, rendel-ui.mjs, could not be loaded from beside rendel.js, twice; Rendel stays hidden on this page. |
insecure_page | Actions and routes need an https page (or localhost). |
theme_contrast | A theme colour pair failed contrast. |
listener_failed | An on(...) listener threw. |
handler_failed | An action handler threw, or returned something that is not JSON. |
handler_timeout | A handler passed its timeoutMs. |
result_too_large | A handler returned more than 32 KB; Rendel passed on its start and told the assistant there is more (before 0.82.0, more than 16 KB failed). |
card_source_failed | The function given to setCardSource threw; the card is drawn without what changes. |
context_provider_timeout / context_provider_failed | A context provider missed its 300 ms budget, or threw. |
route_open_failed | A route's open threw (route_failed before 0.21.1). |
followup_open_failed | A follow-up's conversation could not be loaded; the panel opened as it was. |
invalid_goal / invalid_purchase | track was given a goal name that is not lowercase letters, digits and _ (a letter first, at most 40), a goal value without a three-letter currency, or a purchase without a value of 0 or more and a currency. Nothing was sent. |
invalid_prop | A property given to track or register was left out: a name that is not lowercase letters, digits and _, a value that is not a string, a number, a boolean or null, or one past 20. The rest was sent. |
invalid_screen | setScreen was given an empty name. Use null to go back to the address. |
manifest_sync_failed | Your actions and routes did not reach the server, or it rejected them. Tried again the next time the panel opens. |
transport_failed | A network call failed. |
config_unreadable | The published config could not be read, so it was ignored. |
surface_stale | Debug: a block arrived for a surface_id with a revision no newer than the one on screen, and was not drawn. |
paired | Debug: pair was accepted. |
pair_test_only / pair_not_found / pair_rate_limited / pair_failed | Why pair did not pair: a live key; a wrong, used or expired code; too many tries in a minute; anything else. |
A turn the server ends with an error is logged under that error's own code
(see Errors), and so is a page whose website the key
does not list, as origin_not_allowed: the live key answers localhost until
Go live and only the listed websites from then on, so on your own computer the
log says to use the test key there. A key that is not a key is reported as
invalid_key in the browser console whatever onLog is, because Rendel
does not start.
TypeScript
Types are published beside the file. Save
rendel.d.ts
into your sources and window.Rendel is typed.