Skip to main content
The Widget Creator is the whole Widgetic canvas, with its agentic chat beside it, in your page (see it in the gallery). Your customer draws frames and describes the widget they want in the chat, and the chat’s AI agent does the work: it makes a plan, asks what it needs to know before it starts, builds the widget, checks it and repairs what fails, and suggests what to improve next. The widget appears on the canvas. The customer keeps asking for changes, changes its settings by hand and publishes it. Like every piece, it is mounted with the UI SDK and uses an editor session for one of your managed users, made with the surfaces ["creator", "editor", "files"]. 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 Widget Creator.

Mount it

  • One Widget Creator per page. Its state (the signed-in customer, the chat, the file lists) belongs to the page, so a second one is refused with a clear message. Unmount the first before you mount another.
  • It is the largest piece. It is downloaded when you mount it and not before, and a customer who previews a PDF downloads two more files then. To have it ready sooner, call preload('widget-creator') on a WidgeticUI when the page that will host it opens (see Several pieces on one page). The size of each version is in its entry of the changelog (see Versions & Changelog).

The agentic chat

The chat beside the canvas is an agent. It does not answer once and stop: it works on the customer’s widget until the widget is built, and keeps working on it as the customer asks for more. It is part of the Widget Creator, so there is nothing to mount or style on its own. It needs the same session, and the AI it uses is paid for by your account’s credits (see When a limit is reached).
  • It makes a plan. Before it writes anything, the chat shows what it is going to do, as a plan whose steps are ticked off while it works.
  • It asks when it needs to know. When a request leaves out something it cannot guess, the chat asks a few short questions on one card. Nothing is built until the customer has answered, or has chosen to skip them.
  • It builds, checks and repairs. It writes the widget, builds it and, when the build fails, repairs it, so what reaches the canvas is a widget that runs.
  • It suggests what comes next. Once the widget exists the chat offers ideas for improving it, and a click puts one in the message box.
  • It sees what the customer shows it. A customer can attach pictures and documents to a message (up to 10 MB each: a bigger file is refused before anything is sent), and point at a part of the live preview and write a note about it. Attachments are uploaded in the customer’s session, into your own storage (see Every session needs your own storage), or by your own upload function when you give one (see mediaLibrary below).
  • It works on one widget at a time. Each message after the first changes the widget on the canvas, and the customer can put the widget back as it was after an earlier message.
  • It can be stopped. Stop cancels the generation on the server: the request to the model is aborted and nothing is built or saved from it. A generation stopped before the model began to write gives its credit back. Once the answer has begun to stream the credit is spent, because a generation costs one whole credit and there is no part of it to return.
  • A second tab is told. Another tab of the same browser is told that a generation is running on the widget, follows it until it ends and then brings the widget up to date, so the customer is not left generating the same widget twice. A customer who opens the same widget in another browser or on another device is not told.
  • Your page can set three things: the words (and pictures) of the first message of a new widget, initialMessage; whether a limit is told in the chat alone, limitNotices; and whether the chat’s assistant is Widgetic’s animated mascot, mascot. See Options.

Options

Events and methods

Methods on creator.module: getCanvasId() (the canvas that is open now, or null). creator.setTheme(theme) changes its look (a mode, or settings: see Make the pieces look like your product). creator.setLanguage({ locale?, messages? }) changes its language, and creator.module.defaultMessages and creator.module.checkMessages(messages) list its messages and check yours (see The Widget Creator). creator.unmount() takes the creator away. The methods of your own header are getPublishState(), publish(), flush() and setWidgetName(name, widgetId?).

Where the creator starts

The Widget Creator is independent from your presets: it never puts a screen of its own in front of the canvas, and it never lists your presets, even when you have some. It opens on:
  1. the canvas you give it, as canvasId (and, with widgetId, on one of its widgets);
  2. otherwise the customer’s latest canvas;
  3. otherwise, for a customer who has made nothing yet, a blank canvas to make a new widget on. startWithNewWidget: true asks for one even when the customer has work.
The creator writes nothing to your localStorage, sessionStorage, cookies or address bar, and never opens a window or reloads your page. What it remembers lives in memory until unmount(). So keep the id from canvasChanged with your customer’s record and give it back as canvasId the next time, and the customer finds their work where they left it.

Start a customer from one of your presets

When you want your customers to begin from something ready-made, offer your presets on a page of your own, as Widgetic does with its templates: a list of cards, in your order, and the customer picks one. Your server makes the customer’s copy, and the creator opens on it:
  1. List them. Read your presets from your server (GET /partners/{partnerId}/presets, listPartnerPresets in the SDKs) and draw them as you like: a thumbnail, a title and a line each.
  2. Copy the one the customer picked. Your server calls POST /managed-users/{id}/presets/{key}/copy (copyPresetForManagedUser) with an Idempotency-Key. The answer has the canvasId and the widgetId of the customer’s own copy.
  3. Open the creator on it. Mount it with that canvasId and widgetId, and keep the id canvasChanged gives you for next time.
The customer changes the copy, never your preset. How to register, list and copy presets, what a copy carries and the errors it answers with are in Preset Widgets.

Your own header around the creator

A page that draws its own bar above the creator (a Back arrow, the name of the widget, a Publish button) can put the creator’s own controls aside with showSketchBar: false (the bar with the title, Live and Publish), showSaveButton: false (the Save button and the dot that says the board has changes the server does not have: the creator saves by itself either way), showZoomControls: false (the zoom buttons: the wheel, a pinch and the keyboard still zoom) and toolbarPosition ('BL', 'BC', the default, or 'BR': where the drawing toolbar stands along the bottom edge, for a page that puts something of its own over the middle of it). Then it takes what it needs from the creator:
  • publishStateChanged { widgetId, canPublish, publishing, label, unpublished } says what Publish would do now, for the widget the customer is on. It is said when the creator first knows and at every change, never twice with the same state. label is the words of the creator’s own button, in your page’s language. creator.module.getPublishState() gives the last one to a page that draws its button after the creator reported.
  • creator.module.publish() does what the creator’s own Publish button does and resolves when it is done, after widgetPublished. It rejects, and does nothing, when the creator is not on screen or cannot publish now, and the creator shows the customer the reason, as when its own button is pressed.
  • creator.module.flush() puts what the customer changed on the canvas on the server now and resolves when that is done. Wait for it before your page takes the customer away from the creator.
  • creator.module.setWidgetName(name, widgetId?) renames the widget the customer is on (or the one you name), shows the new name at once and saves it, and the creator says widgetRenamed.

What the creator makes, and how you find it

Everything the creator makes is filed under the session’s managed user, and the session can open only that customer’s canvases, widgets and compositions. Another customer’s canvas answers 404, exactly as if it did not exist.
  • Find a customer’s work from your server with the filter you already know. Your key sees all of it:
    GET /canvases and GET /compositions take the same managedUserId and managedUserExternalId filters.
  • Show the result in your product the way you show any widget: a composition of the widget, and the embed code. The creator makes compositions of the widgets it builds to show them with sample values; you can list them with the filter above or make your own on the same widget with your key.
  • Private to your account. A widget a customer builds is never made public in Widgetic’s catalogue by a session. Publishing a version saves it and the customer can go back to an earlier one.
  • Your key reaches everything, filed under a customer or not. Deciding which of your customers may see which widget stays in your own platform.

When a limit is reached

The AI is paid for by your account (see Credits & Billing), and your credits and your plan are yours: a customer is never told what they hold. When one is used up, the API refuses the session with one plain sentence, “This is not available right now. Please try again later.”, and the creator shows exactly that, in the chat (with an Upgrade button under the failed message: see The Upgrade button) and in a toast, and keeps working: the canvas, the chat and the other widgets are still there. It also tells your page, with limitReached { message: 'The visitor reached a limit.', code }. The code is what the API answered: Your page hears each code once in half a minute, however many requests are refused meanwhile. Ordinary rate limiting (RATE_LIMIT_EXCEEDED) is not a limit: the creator asks the customer to wait a moment and tells your page nothing. The allowance of the hour or the day is counted for each customer on their own, so one customer reaching it refuses and tells nobody else. Credits and plan are your account’s, so when they run out every customer is refused. A customer’s upload that cannot be kept, because you have set up no storage of your own (409 PARTNER_STORAGE_REQUIRED), is not a limit: your page hears no limitReached for it, and the customer reads the same plain sentence. You find out when you make the session, which is refused for the same reason. See Every session needs your own storage. A paused, stopped or not yet activated partner account, or a partnership that has ended, is not a limit either: the customer reads one plain sentence, “This service is not available right now. Please contact the website that sent you here.”, and your page hears no limitReached for it. See Account Status and Ending a Partnership.

The Upgrade button

When what failed is about credits or the plan, the chat draws an Upgrade button under the failed message, and the notice that says a publish is not in the plan has one too. Your customer has no plan of their own to upgrade, so the creator opens no page and no window for it. A press tells your page, with limitReached and code: 'LIMIT_REACHED', and your page decides what it means: your own plans or top-up page, a dialog, a message to the owner of the account.
A page whose plan already includes making a widget passes offerPlanUpgrade: false. The chat then draws no Upgrade button (a failure about credits or the plan gets the same Retry as any other failure), and nothing reports LIMIT_REACHED. The other codes in the table above are told to your page as they happen, whatever this option says.

When something goes wrong

The creator shows a problem to the customer itself. The error event is for your page. fatal: true means the creator cannot go on, and it has said so on its own screen:
  • The session is over (sessionEnded: true, for example EDITOR_SESSION_EXPIRED or EDITOR_SESSION_REVOKED). Mount again, with a new token from getToken.
  • The canvasId you gave is not this customer’s (during: 'canvas', code NOT_FOUND). Mount again without it.
Either way no ready comes, and the creator stops asking the API. With fatal: false the creator carries on (for example after a failed token refresh that will be retried).

What it leaves alone

  • The keyboard. The canvas’s shortcuts (Delete, the arrows, v, r, h, Ctrl+A and so on) work only while the focus is inside the creator, so a customer who clicked on your page keeps every key of it. Your page’s own zoom (Ctrl or Cmd with +, -, 0, Ctrl with the wheel) works everywhere. A customer gives the creator the keyboard by clicking on it or tabbing into it.
  • Your page’s scroll. The chat follows its newest message inside its own box and never scrolls your page.
  • Your <head> and <body>. The creator adds one <style> with font rules to <head> (named Widgetic UI …, shared with the other pieces and never added twice, so it stays when the creator is unmounted) and draws everything else inside its shadow root.
  • A widget’s compositions. The creator’s Edit step (a widget’s compositions) and its Embed step are not part of a session, and a page cannot switch them on. A customer edits a composition with the Composition Editor, and your page shows the widget with the embed code.

Next Steps

Editor Sessions

Make the token on your server

Preset Widgets

Offer your customers a ready-made start

Managed Users

File your customers’ work under them

Compositions

Show a widget in your product with the embed code