["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: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 resolvetruewhen nothing is left unsaved),embed.module.isDirty()tells whether anything is unsaved, andembed.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 anerrorwith the codeUNSAVED_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
editorsurface 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
429and the codeRATE_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 plainhttpsaddress 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 sameembedSettings 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:
When something goes wrong
- Problems are shown to the customer by the editor itself, with Try again where that helps.
erroris for your page, and addsduring('load','save','token'or'unmount'),status,retryable,sessionEndedandcorrelationIdto the usual fields.fatal: truemeans 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. QuotecorrelationIdto 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