# JavaScript reference (https://notert.io/docs/widget/javascript-api)

Last updated 2026-11-24

The snippet puts one object on the page, `window.notert`. Every call can be made before the widget has loaded: the snippet keeps them in order and the widget plays them back once it arrives.

Building with TypeScript or React? The [npm package](/docs/widget/npm-package) has these calls typed, and a hook for your own Help button.

## init [#init]

```js
window.notert.init(workspaceId, options);
```

Draws the widget for a workspace. It waits for your page to finish loading and for a quiet moment before it draws anything.

- **`workspaceId`** (string, required) is your workspace's id, which the install guide writes into the snippet.
- **`options.theme`** (`"page"`, `"light"`, `"dark"` or `"auto"`) sets the theme. It's `"page"` when left out, and draws as your page does; `"auto"` follows the visitor's system setting. See [light, dark or match your site](/docs/widget/theme).
- **`options.widget`** (boolean) loads the widget when `true`, which is the default. Pass `false` to load nothing on a page where you'd rather not have it: no round button, no panel, and your own buttons and `open` open nothing there.
- **`options.launcher`** (boolean) draws the round button in the corner when `true`, which is the default. Pass `false` to open the widget from a button of your own instead, such as Help in your app's sidebar. See [your own button](#your-own-button).
- **`options.titleNotice`** (boolean) puts how many replies wait at the start of your page's title, such as `(1) Billing`, when a reply arrives while your visitor is in another tab, whether they left the widget open or closed. It's `true` when left out. Your title comes back as it was as soon as they return to the tab or read the reply elsewhere, and a title your page sets meanwhile is kept. Pass `false` to leave your page's title alone.
- **`options.closeOnBack`** (boolean) lets a phone's Back gesture or button close the widget while it fills the screen, rather than leave your page. It's `false` when left out, since a single-page app keeps its own history: when `true`, the widget adds one entry to your page's history as it opens full screen, at the same address and keeping your page's state, and takes it away again when your visitor closes it another way. Leave it off if your router reacts to every Back. See [single-page apps](/docs/widget/single-page-apps#let-back-close-it-on-a-phone).
- **`options.appearance`** (object) sets the widget's look for the page, on the Professional plan. See [set its look for a page](/docs/widget/appearance).
- **`options.language`** (string) is the language your visitors read, for a widget that would otherwise speak your workspace's default. See [choose its language](#choose-its-language).

Only the first call that draws the widget counts, so calling `init` again on the same page changes nothing. Any option the widget doesn't know is ignored.

## Choose its language [#choose-its-language]

```js
window.notert.init("YOUR_WORKSPACE_ID", { widget: true, language: "de" });
window.notert.init("YOUR_WORKSPACE_ID", { widget: true, language: "page" });
window.notert.appearance({ language: "fr" });
```

The widget speaks your workspace's default language unless your page names another. Pass one of the widget's languages, such as `"de"`, `"fr"` or `"pt-BR"`, or `"page"` to use your page's own `<html lang>`, such as `es-MX`, which reads as Spanish. With `"page"`, the widget follows your app as it changes `<html lang>` without a reload.

- **Only languages your workspace offers are spoken.** One it doesn't offer, as your board's languages in Notert set them, gives way to your default, as a signed-in user's `language` claim does.
- **A signed-in user's token comes first.** A token that names a `language` for its user is used over what your page names. See [sign a token on your server](/docs/signed-in-users/sign-a-token).
- **Your visitor's browser decides nothing.** The widget never reads the browser's languages, since your product chose its own language.
- **Emails follow it.** The code a visitor confirms their email with, and the emails about their conversations, are written in the language the widget showed them.
- **`appearance({ language })` changes it later**, such as from your app's own language menu. The widget reads its words again in the new language, open or shut. Pass `null` to go back to your default.

A value that isn't one of the widget's languages or `"page"` is left out with a warning in the browser's console.

## identify [#identify]

```js
window.notert.identify(token);
window.notert.identify(async () => fetchNotertToken());
window.notert.identify(null);
```

Tells the widget who is signed in to your site, by a token your server signed for them, or a function that fetches one. Pass `null` once they sign out. See [identify your signed-in users](/docs/signed-in-users/identify-users).

- Call it before `init` or after: either order works.
- The token is kept in the page's memory only, never in storage, so call `identify` on every page load while they're signed in.
- A token for someone else, or `null`, starts the widget over for them, with nothing it read for the one before. A fresh token for the same user, by its `sub`, keeps the widget as it is.
- Only `null` signs them out. Anything else that isn't a token, such as `undefined` from a value your page doesn't have in the browser, changes nothing and says so in the console.

### Keep a token fresh [#keep-a-token-fresh]

A token lasts a day at most, so a tab left open overnight would lose the user it names. Pass a function that returns a fresh token, or a promise of one, and the widget asks it whenever it needs one:

- **At once**, and the widget waits for its answer before it reads anything, so it never shows the user as someone else first.
- **About 5 minutes before each token's `exp`**, so calls go on naming the user.
- **Once more when a call is refused because its token expired**, as when a laptop wakes up the next morning. The refused call is then sent once more with the new token.

If the function throws or returns anything but a new token, the widget goes on with the token it has and says so once in the browser's console. Calling `identify` again with a token or `null` stops the widget from asking.

## Your own button [#your-own-button]

Any element carrying `data-notert-toggle` opens the widget when pressed, and closes it when pressed again:

```html
<button type="button" data-notert-toggle>Help</button>
```

- It works on buttons and links your app draws later, after a page change in a single-page app too.
- A press made before the widget has loaded opens it as soon as it has.
- When the widget closes, the focus goes back to the button that opened it.
- It works with the round button in the corner too, so you can keep both.

Pass `launcher: false` to `init` to leave out the round button.

Your button can wear what the round button does: a green dot while your team is online, and how many replies wait unseen in its place. It can also tell a screen reader whether the widget is open, which the widget leaves to your page, since the button is yours:

```html
<button type="button" data-notert-toggle aria-expanded="false">
  Help
  <span id="help-online" hidden></span>
  <span id="help-badge" hidden></span>
</button>

<script>
  window.notert.on("change", ({ open, unseen, online }) => {
    const button = document.querySelector("[data-notert-toggle]");
    const dot = document.querySelector("#help-online");
    const badge = document.querySelector("#help-badge");
    button.setAttribute("aria-expanded", String(open));
    dot.hidden = !online || unseen > 0;
    badge.textContent = unseen > 0 ? String(unseen) : "";
    badge.hidden = unseen === 0;
  });
</script>
```

Put the script after the snippet, so `window.notert` exists. Style `#help-online` as a small green dot and `#help-badge` as a count. See [on and off](#on-and-off) for what each value means.

## open, close and toggle [#open-close-and-toggle]

```js
window.notert.open();
window.notert.close();
window.notert.toggle();
```

Open or close the widget from your own code, as `data-notert-toggle` does. The element that has the focus when you open it gets it back when the widget closes.

### Open it on a screen [#open-it-on-a-screen]

```js
window.notert.open({ screen: "help", article: "0b7e0c8e-6f1a-4c55-9d4c-0e2a0d6c1f00" });
window.notert.open({ screen: "new", text: "I found a bug: " });
window.notert.open({ screen: "request", title: "Export to CSV" });
```

Pass a `screen` to open the widget on it, such as from a link beside a field your customers ask about, or a Report a bug item in your app's menu. `toggle` takes the same.

| `screen`         | With                            | Opens                                                                                           |
| ---------------- | ------------------------------- | ----------------------------------------------------------------------------------------------- |
| `"help"`         | `article`, optional             | The Help tab, or one help article. An article's ID is the last part of its address in Notert.   |
| `"messages"`     |                                 | The visitor's conversations.                                                                    |
| `"new"`          | `text`, optional                | A new conversation, with `text` written in its box for the visitor to send or change.           |
| `"conversation"` | `id`                            | One of the visitor's conversations, such as one your page heard of from `conversation:started`. |
| `"feedback"`     |                                 | The Feedback tab, with your board's requests.                                                   |
| `"request"`      | `title` and `details`, optional | The form for a new request, with `title` and `details` written in it.                           |
| `"request"`      | `id`                            | One request, such as one your page heard of from `request:submitted` or `vote`.                 |
| `"roadmap"`      |                                 | Your roadmap.                                                                                   |
| `"news"`         |                                 | Updates, your published updates.                                                                |
| `"post"`         | `id`                            | One published update.                                                                           |

- **Back returns to the list a screen sits in**, such as Help from an article, Messages from a conversation and Feedback from a request.
- **Nothing is sent by itself.** Words your page writes into a box wait there for your visitor, and never take the place of what they've already written in it.
- **The widget opens only what your visitor may see.** A new conversation opens Messages instead while your team takes none; the request form opens Feedback, which says why, for a visitor who may not post, and asks one who must confirm their email to do so first; a conversation that isn't theirs, or a request or update they can't see, leaves for its list. While a list is off, as your help center or roadmap can be, the widget opens where your visitor left it.
- **What your page passes is checked.** IDs must have the shape the widget's own have, text must be a string and is cut to the length of a message, and anything else opens the widget where your visitor left it, with a warning in the browser's console.

A button's `data-notert-toggle` can name any screen that needs no `id` or text, so a menu of your own can open each part of the widget:

```html
<button type="button" data-notert-toggle="help">Help center</button>
<button type="button" data-notert-toggle="new">Contact us</button>
<button type="button" data-notert-toggle="request">Suggest a feature</button>
<button type="button" data-notert-toggle="roadmap">Roadmap</button>
```

`data-notert-toggle` takes `help`, `messages`, `new`, `feedback`, `request`, `roadmap` and `news`. An empty value, or one it doesn't know, opens the widget where your visitor left it.

## context [#context]

```js
window.notert.context({ plan: "team", cartId: "c_8f2a", trial: true });
```

Tells the widget facts about the page and the visitor, such as their plan, a cart id or an error code your page just showed. The latest set goes with the visitor's next message or request, not on a call of its own, and your team sees it beside the conversation, under "From the page". Each call replaces the last set, and `context(null)` clears it.

- **Up to 20 keys**, each starting with a letter, then letters, digits and `_`, up to 40 characters.
- **Each value** a string up to 255 characters, a number or a boolean. A key or a value that doesn't fit is left out on its own, with a warning in the console.
- **It's unverified.** Anyone can call it from the page, so your team sees it as the page's word, and it never decides who the visitor is. To tell the widget who your signed-in user is, sign a token for [`identify`](#identify), whose traits are verified.
- **It's yours alone.** No other visitor ever sees it, and neither does this one.

Call it before `init` or after, and again whenever the facts change. `shutdown` forgets it, and so does the signed-in user `identify` named signing out or another one signing in, so the next person's messages never carry the last one's facts. A visitor who signs in keeps what your page said before.

## track [#track]

```js
window.notert.track("checkout.failed", { code: "card_declined", attempt: 2 });
```

Records something the visitor did, which your team reads as a short timeline beside their conversation. Record what helps your team answer, such as a plan picked or an error, by its ids, never what anyone wrote.

- **A name** starts with a letter, then letters, digits and `_ . : -`, up to 64 characters, such as `plan.upgraded`.
- **Meta**, optional, holds up to 5 keys, named as `context`'s are, each a string up to 100 characters, a number or a boolean.
- **It's sent in batches**, a few seconds after your page records something and with the visitor's next message or request, so a busy page doesn't make a call for each one.
- **Only a visitor who has written keeps them**, the latest 20. Before a visitor first writes, events wait in the page and go with that first message, so a visitor who never writes sends nothing.

A name or meta that doesn't fit is left out with a warning in the console. `shutdown`, and a signed-in user signing out, drop what hasn't been sent.

## hideLauncher and showLauncher [#hidelauncher-and-showlauncher]

```js
window.notert.hideLauncher();
window.notert.showLauncher();
```

Hides the round button in the corner while your page shows something of its own there, such as a checkout's pay button or a full-screen editor, and shows it again. A hidden button can't be reached with Tab either, and the preview of a new reply that stands over it waits until it shows again. Your own buttons, `open` and the rest work as before. Call either before `init` or after: the button stays as you left it until you call the other one. To leave the round button out for good, pass `launcher: false` to `init`. To keep it off some pages, or off phones, without code, see [where the launcher shows](/support/conversations/customize-the-widget#where-the-launcher-shows): `showLauncher` doesn't bring it back where those settings hide it.

## suggest [#suggest]

```js
window.notert.suggest(["0b7e0c8e-6f1a-4c55-9d4c-0e2a0d6c1f00"]);
window.notert.suggest([]);
```

Names the help articles the widget's first screen suggests on this page, in place of the ones your team suggests on it, such as on a screen of your app whose address doesn't tell it apart from others. Pass `[]` to go back to your team's.

- **Up to 3 articles, in the order you name them**, by their IDs: an article's ID is the last part of its address in Notert. Past that the widget keeps the first ones, and leaves out anything that isn't an article's ID, each with a warning in the browser's console. Anything but a list changes nothing.
- **Only an article your help center lists is suggested**: published, public, and in a collection or at the top level. The ID of any other, or of one that's gone, is passed over.
- **Your most read articles fill the rest**, as they do on a page nothing is suggested on.
- **It lasts while the page does.** Call it again as your single-page app moves to another screen. Call it before `init` or after, and `shutdown` forgets it.
- **A suggested article opens as the Help tab's do**: it counts as read, and your page hears `article:viewed`.

## on and off [#on-and-off]

```js
const listener = ({ open, unseen, online }) => {
  document.querySelector("#help-badge").textContent = unseen > 0 ? String(unseen) : "";
};
window.notert.on("change", listener);
window.notert.off("change", listener);
```

Tells your page whether the widget is open, how much waits unseen and whether your team is online, so your own button can show the count the round button does. The round button's What's new mark, naming your newest update, and its mark for a message that didn't send aren't among them. Your listener is called once the widget has loaded, and again whenever something changes.

- **`open`** (boolean) is whether the widget is open.
- **`unseen`** (number) is how many messages the visitor hasn't seen yet: your team's replies, and the updates sent about a request of theirs, such as one that moved on your roadmap. A reply in a conversation that's still going counts as it arrives; one in a conversation that went quiet, or that arrives while your page is in another tab, counts within about a minute.
- **`online`** (boolean) is whether someone on your team is available to answer: using Notert, or within their working hours, and not appearing offline. While the widget is closed it's checked every 60 seconds your page is in view, and as soon as the page comes back into view, so it follows your team within about a minute of them coming online or leaving. Show it as a green dot on your button, as the round button does, and hide the dot while `unseen` shows a count.

In React, Vue or Svelte, set `unseen` in your component's state from the listener, add it when the component mounts and remove it with `off` when it unmounts.

### What happened in the widget [#what-happened-in-the-widget]

```js
window.notert.on("conversation:started", ({ conversationId }) => {
  analytics.track("Support conversation started", { conversationId });
});
window.notert.on("open", () => pauseVideo());
```

Beside `change`, the widget tells your page what happens in it, such as for your analytics or to pause what your page plays while the panel is open. Each event comes once, as it happens, and `off` with the same event and listener stops it.

| Event                    | Your listener gets   | When                                                                                               |
| ------------------------ | -------------------- | -------------------------------------------------------------------------------------------------- |
| `"open"`                 | nothing              | The panel opens, by your visitor, your own button or your page's call.                             |
| `"close"`                | nothing              | The panel closes, or goes as the widget starts over for someone else.                              |
| `"message:sent"`         | `{ conversationId }` | Notert has your visitor's message.                                                                 |
| `"conversation:started"` | `{ conversationId }` | Your visitor's first message in a new conversation reached Notert, just before its `message:sent`. |
| `"request:submitted"`    | `{ requestId }`      | Notert has a request your visitor posted.                                                          |
| `"vote"`                 | `{ requestId }`      | Notert counted your visitor's vote for a request. Taking a vote back tells nothing.                |
| `"article:viewed"`       | `{ articleId }`      | A help article shows in the widget, each time your visitor comes to it.                            |

- **They carry IDs alone.** No event holds what your visitor or your team wrote, a request's title, or who your visitor is, so they're safe to send to an analytics tool. Open a record by its ID with [`open`](#open-it-on-a-screen), or read it through Notert's API.
- **They follow Notert's answer.** A message, a request or a vote tells your page once Notert has it, never as it's pressed: one that doesn't go through, such as a message while your team takes none, tells nothing.
- **A listener that throws** is reported in the console and stops neither the widget nor your other listeners. An event the widget doesn't have is left out with a warning in the console.

## shutdown [#shutdown]

```js
window.notert.shutdown();
```

Takes the widget off the page without a reload, such as when someone your page must not show it to signs in: the round button, the open panel and what it read go, its connection to Notert closes, and it forgets the signed-in user `identify` named, the language your page named, the articles it named to `suggest`, the facts `context` gave and the events `track` hadn't sent yet. Your own buttons carrying `data-notert-toggle` go back to what they do without it, and your `on("change")` listeners hear that nothing waits, so a count or a dot on your button clears.

Call `identify` and then `init` again to start it for the next person. A visitor who isn't signed in keeps the `localStorage` key described [below](#what-the-widget-keeps-in-the-browser), so they find their conversations again. On a computer people share, pass `forget: true` to let go of it too, with any message of theirs that didn't send, the moment of the last reply its card showed them and that of the last update What's new showed them, and the next person who opens the widget there starts as a new visitor:

```js
window.notert.shutdown({ forget: true });
```

## appearance [#appearance]

```js
window.notert.appearance({ theme: "dark" });
```

Changes the widget's theme, or its look, after `init`, such as when a visitor flips your app's own dark-mode switch. The widget follows at once, open or shut, and each call goes over the last.

- **`theme`** (`"page"`, `"light"`, `"dark"` or `"auto"`) works on every plan, as `init`'s does. See [matching your site's own theme switch](/docs/widget/theme#matching-your-sites-own-theme-switch).
- **`launcherSide`, `launcherOffsetX` and `launcherOffsetY`** move the launcher and the panel, on every plan. See [move the launcher](/docs/widget/appearance#move-the-launcher-on-any-plan).
- **`zIndex`** sets where the widget stacks among your page's own layers, on every plan. See [stack it with your page's layers](/docs/widget/appearance#stack-it-with-your-pages-layers-on-any-plan).
- **`language`** changes the language the widget speaks, on every plan. See [choose its language](#choose-its-language).
- **Any other value `appearance` takes at `init`**, such as `accent`, applies on the Professional plan. See [set its look for a page](/docs/widget/appearance).

## What the widget keeps in the browser [#what-the-widget-keeps-in-the-browser]

- **No cookies.** The widget never sends one.
- **A key in `localStorage`** per workspace, `notert:visitor:<workspaceId>`, made the first time a visitor opens the panel. It's how a visitor who isn't signed in finds their conversations again on their next visit. While a visitor confirms their email address, a second one, `notert:visitor-next:<workspaceId>`, sits beside it, with `notert:visitor-next-at:<workspaceId>`, when it was last sent. A visitor who never opens the widget gets nothing stored.
- **When the newest reply it previewed was sent**, under `notert:reply-shown:<workspaceId>`. While the widget is closed, a reply from your team shows in a card above the round button, once: a later page shows the card again only for a newer reply. A visitor who never gets a reply gets nothing stored, and `shutdown({ forget: true })` removes it.
- **When the newest update What's new showed was published**, under `notert:news-seen:<workspaceId>`. The round button and What's new wear a mark while an update newer than it waits, until the visitor is shown it. `shutdown({ forget: true })` removes it.
- **A message that didn't send**, until it's sent or deleted. If the widget couldn't reach Notert, the message waits in its conversation with Retry, and a visitor who isn't signed in still finds it there after a reload or on your next page, ready to send again: its words in `localStorage` under `notert:draft:visitor:<workspaceId>:support-unsent`, its files in IndexedDB. Whatever isn't sent goes after 30 days.
- **Nothing that names a signed-in user.** A visitor your site identifies is recognized by your token alone, and a message of theirs that didn't send stays only until the page closes, so signing out leaves nothing of theirs behind.