Skip to main content
The Embed Editor lets a customer decide how and where a widget of theirs shows on a page: how big it is, whether it sits in the page or opens in an overlay and where, what makes it appear (the visitor leaving the page, a delay, scrolling, page views), which pages and visitors it is for, when it runs and how often it may be shown. It writes the embed code to paste from those options, and an assistant beside the options sets them from a sentence the customer types (see it in the gallery). It is the Embed panel of Widgetic’s own site, drawn in your page. The Composition Editor changes what a widget says; this one changes how it is shown, so a page that offers both mounts both. Embed Settings says what each option is called and what it does. Like every piece, it is mounted with the UI SDK and uses an editor session for one of your managed users, made with the surface ["editor"]. It has no file picker, so files is not needed, and a session made for the Composition Editor (["editor", "files"]) serves it too. Installing the SDK, tokens, the theme, the language and the Content Security Policy are the same for every piece, and are on the UI Components page. This page covers what is specific to the Embed Editor.

Mount it

Create the composition on your server with your key and file it under the customer (see Filing Content Under a Managed User). A session opens only compositions filed under its customer. Then mount the editor on it:
More than one Embed Editor can share a page. Each takes one composition, in a box of its own, and keeps its own options.

Options

Events

The code

ready and saved carry embedCode, the code the options make, and embed.module.getEmbedCode() reads it at any moment, unsaved changes included, for a page that shows the code somewhere else too. It is null before the options are on screen. The code names the Widgetic embed script and the frame; snippetBases says where they are.

Saving

  • The editor saves by itself shortly after the last change, and when a tab that holds unsaved changes is closed or hidden. embed.module.save() saves what is unsaved now, embed.module.flush() saves everything unsaved and waits until it is (both resolve true when nothing is left unsaved), embed.module.isDirty() tells whether anything is unsaved, and embed.module.reload() reads the options again, which drops unsaved changes.
  • A save that fails because of the network or the server is tried once more by itself a moment later, and every failed attempt is an error. A save the API refuses for good, because an option is not one it accepts, is not tried again: what failed stays unsaved, and the editor says so.
  • unmount() saves first, for up to 10 seconds, so closing the editor never loses the last changes. If some could not be saved you hear an error with the code UNSAVED_ON_UNMOUNT. embed.module.unmount({ discard: true }) throws unsaved changes away instead.
  • A customer’s options are their own. The options a customer saves stay on their composition. They never become the starting options of the widget for anyone else, so no other customer’s composition begins from them.

The assistant

The assistant is a second column beside the options. The customer writes what they want (“show it when they are about to leave, once a day”), and it sets the options, asks a question when it needs to, and shows every change it makes in the options before they are saved. It answers in the language the customer writes in.
  • It uses no AI credits. Nothing is charged to your account or to the customer for its answers. Other AI inside an editor session, such as the chat of the Widget Creator, still spends your account’s credits.
  • It needs nothing more than the options do. It works with the same session token, so the session made with the editor surface is enough. If Widgetic has switched the assistant off for every caller, the assistant cannot answer while the options go on working.
  • A customer can send up to 30 messages a minute, counted for each customer, so one busy customer does not slow another down. A message over the limit is refused with 429 and the code RATE_LIMIT_USER_EXCEEDED, and the assistant tells the customer to wait.
  • What it writes is shown as text. Markup, a script, a picture or a javascript: link in an answer is shown as words and never runs or loads, and a plain https address becomes a link that opens in a new tab.

Next to the Composition Editor

The Composition Editor saves the size of its preview in the same embedSettings that this editor saves everything else in, and each sends back what it loaded with every save. Without a word from your page, whichever saves second puts the other’s options back. So tell each about the other’s saves:
Nothing becomes unsaved by it, and what the customer changed here and has not saved yet stays as it is.

When something goes wrong

  • Problems are shown to the customer by the editor itself, with Try again where that helps. error is for your page, and adds during ('load', 'save', 'token' or 'unmount'), status, retryable, sessionEnded and correlationId to the usual fields. fatal: true means the editor cannot go on: the composition cannot be opened, or the session is over (sessionEnded: true). Make a new session or take the editor away. Quote correlationId to Widgetic’s support.
  • Another customer’s composition is answered with 404, and the editor says it cannot be opened.

Next Steps

Editor Sessions

Make the token on your server

UI Components

The SDK, tokens, the look and the language of every piece

Managed Users

File your customers’ compositions under them

Embed Settings

What each option is called and what it does