<widgetic> tag you already use: the embed follows the workflow, so the composition on screen is replaced by the next one, in the same place.
You can put the screen where workflows are built (see it in the gallery) in your own page, for one customer at a time. Your customer makes workflows from their own compositions, tries them, publishes them and pauses them, without leaving your product and without a Widgetic account. Your server keeps your API key. The page only holds an editor session. Your server can also read and change your customers’ workflows itself, one customer at a time (see From your server). And you can offer your customers somewhere to start: workflows of your own that they copy and build on, from a page of yours (see Starting points).
Like every piece, it is mounted with the UI SDK, and 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 Workflows.
A customer can make workflows in their own browser. A/B tests and translations have no screen in a session: your server makes them for the customer, with your key and the customer’s header (see A/B Tests and Translations).
How it works
1
Your server makes an editor session
When the page that holds the screen opens, your server asks Widgetic for a session for the signed-in customer, with the
workflows surface, and returns the token. See Make a session.2
Your page mounts the screen
The UI SDK draws it in your container, with the id of your partner workspace as its
workspaceId and a getToken that fetches the token from your server. See Mount the screen.3
Your customer builds and publishes
They chain their own compositions, play a visitor through the draft with Test run, and publish. Every call the screen makes carries the token, so it reaches that customer’s workflows and compositions and nobody else’s. See What belongs to whom.
4
Your page shows the embed tag
The screen tells your page which workflow the customer asked the embed code of, and your page shows the
<widgetic> tag that goes on the customer’s own page. See Show a workflow on a page.Make a session
Call this from your server, as for any other piece (see Editor Sessions).{id} is Widgetic’s id for the managed user, not your own externalId.
workflowsis enough on its own. The screen, its assistant included, calls nothing outside its own workflow calls. Addfilesonly when your customers should be able to attach a file to a message of the assistant: the screen then uploads it first, with the same session. A page that also mounts the Composition Editor or the Widget Creator asks for their surfaces in the same call, because the surfaces do not imply one another.- The rest is the same as for every session. The token is shown once, the session lasts up to four hours,
allowedOriginbinds it to your page, and it is made only while your account is in force and your own storage works, even though this screen stores no file of its own (an attached file goes to your storage). - One endpoint of yours serves every piece. The endpoint in A server endpoint for your page makes the session with the surfaces the page needs.
Mount the screen
Give the container a height: the screen fills it and scrolls inside it.workspaceIdis required. It is the id of your partner workspace, where your customers’ workflows are filed, and it is theworkspaceIdthat the answer of every editor session carries, the same for all your customers. Keep it in your page’s configuration, or have your endpoint send it with the token. An editor session can make only the workflow calls of that workspace, and the workflows it shows are its customer’s own: the id of any other workspace is refused with404andRESOURCE_WORKSPACE_NOT_FOUND, and a word where the id belongs (me, say, which is not a workspace) with403andEDITOR_SESSION_ROUTE_NOT_ALLOWED. The screen then says that something went wrong, with a Try again button, and does not show an empty list in its place.getTokengives the token of the customer’s editor session, made with theworkflowssurface (see Make a session): the screen then reaches that customer’s own workflows and compositions, and nothing else. A session that was made without theworkflowssurface is refused with403andEDITOR_SESSION_ROUTE_NOT_ALLOWED.getTokenis called once before the screen appears (agetTokenthat fails fails the mount), and again when the token is about to run out or the API refuses it (reason: 'expired', once per refusal), as in Tokens. The screen never stores a token, and no API key ever reaches the page. When the session ends, the screen tells your page with anerrorevent (SESSION_ENDED).- Your page owns where the person is. The screen opens
workflowIdfirst, and the list when you leave it out. When the person opens a workflow or goes back to the list, the screen says so withopenWorkflow(workflowIdisnullfor the list), so your page can keep its address in step. When your page moves, as with the back button,workflows.module.setWorkflow(workflowId)moves the screen (nullfor the list). The screen writes nothing to your address bar, your storage or your cookies. - The embed code is yours to show. The screen has its Embed code button only when something listens for
showEmbedCodeat the moment it mounts, and only for a workflow that has been published. See Show a workflow on a page. - Look and language are as for the other pieces.
theme,setTheme,locale,messagesandsetLanguagework as described in Make the pieces look like your product and Show the pieces in the language of your customers, the 65 built-in languages included, and a language written right to left turns the screen around. - Events.
ready,openWorkflowandshowEmbedCode(above), anderror.errorhasfatal: truewhen the screen could not start (andmountModulerejects as well). Withfatal: falsethe screen carries on:RENDER_FAILED(a part of it could not be drawn: the rest stays and the person is offered “Try again” in its place),REQUEST_FAILED(a request to the API failed: the screen tells the person by itself),SESSION_ENDED(the API no longer accepts the tokengetTokengives) andTOKEN_REFRESH_FAILED(a refresh of the token failed and will be tried again). - What it weighs. It is downloaded when you mount it, and only then: about 0.2 MB gzipped to start, and about 0.3 MB gzipped once all the parts of the editor have been loaded. What each version of the screen changes is in Versions & Changelog.
What a customer can do
With a session, the screen offers a customer what it offers anybody:- The list. The customer’s own workflows, with search, sort and a switch for the archived ones.
- A new workflow. New workflow makes a blank workflow at once, named Untitled, and opens it. The customer names it and chooses the composition of each block in the editor, from their own compositions. The screen offers no starting points of its own (see Starting points).
- The editor. A canvas of blocks that go forward only (up to 25), a draft that is saved while they work, and Test run, which plays a visitor through the draft.
- Publish and Discard changes. A published version never changes. The customer can read the history of versions and restore one as a new draft.
- Settings. The time zone, the Embed code button, pause and resume, archive and unarchive.
- Duplicate and delete. A duplicate is a new draft. A customer can delete a workflow in any state (see Delete a workflow).
- Runs. How many visitors went through each block.
- The assistant. A chat beside the canvas that reads the open workflow, tries it and changes the draft for them, with their own compositions (see The assistant beside the canvas).
403 and EDITOR_SESSION_FIELD_NOT_ALLOWED.
Delete a workflow
A customer can delete a workflow in any state: a draft, a live workflow, a paused one or an archived one. The screen asks them to confirm and says what goes: the draft, the published versions and the counts, with how many visitors the workflow had so far. It cannot be undone: archiving is what keeps a workflow. The compositions it chained are not touched. A page whose embed still names the deleted workflow does not break. It shows the embed’s first composition, as it does for a paused workflow. Your webhook is told (workflow.deleted, see What you are told).
Your server deletes with DELETE /workspaces/{workspaceId}/workflows/{workflowId} and the customer’s header (see From your server). A workflow that is already gone answers 404 with RESOURCE_WORKFLOW_NOT_FOUND.
The assistant beside the canvas
The screen has a chat beside the canvas, the Workflow assistant. With a session your customer has it too, and it works for that customer alone: it is the chat a person signed in on widgetic.com uses, in a smaller edition. Your customer can ask it, in their own words, to:- Read the workflow that is open and say what it does.
- Change the draft: add or remove blocks, rename the workflow and change how the blocks lead to one another. The screen shows the new draft while the assistant is still answering. It only ever changes the draft, so the live version does not move until the customer publishes.
- Try it. It plays a visitor through the draft, as Test run does, without publishing anything.
- Use their own compositions as the blocks of the path, by name.
- Their own compositions only. The compositions it can offer, and the ones the customer mentions in a message, are the ones filed under that customer. Another customer’s composition, one you made for yourself and one that does not exist all read as missing, and a message that names a workflow or a composition that is not theirs is refused with
404, the same one that answers for something that does not exist. - Never a publish, a pause or a delete. Those are the buttons of the screen, and the customer presses them.
- No widgets, no templates, no plans. It does not build widgets, copy templates or make a plan, so it changes nothing outside the open workflow.
- No suggestions in the box. The box does not offer what to write next for a customer.
- A file is an extra. A customer can attach a file to a message when the session also has the
filessurface (see Make a session). The file is theirs, in your storage, and the assistant does not put a file into a composition.
What belongs to whom
- A workflow is filed under the customer when it is made. A workflow made in a session is filed under the session’s managed user, at that moment. The session cannot change that, as it has no field to name another customer. You can move it to another customer, or take the label off, from your server with your own key: see Moving Content to Another Managed User.
- A customer sees their own workflows only. Another customer’s workflow, one of yours and one that does not exist all answer
404with the codeRESOURCE_WORKFLOW_NOT_FOUNDand the same words, so the customer cannot tell them apart. A workflow id that is not an id is not a route at all: it answers403andEDITOR_SESSION_ROUTE_NOT_ALLOWED. - A customer chains their own compositions only. The compositions the screen offers are the ones filed under that customer (see Content the editors can open). Another customer’s composition, one you made without naming a customer and one of another account all read as missing: starting a workflow from one answers
404withRESOURCE_COMPOSITION_NOT_FOUND, and a draft that holds one as a block cannot be published (422withBUSINESS_OPERATION_INVALID, and the block is named). - Your account owns the workflows. They run under your account and your agreement, as your compositions do. While your account is paused or stopped by an unpaid invoice, a workflow is not served either (see Account Status). When your partnership ends, workflows are still served during the 60-day wind-down, and not once it is closed (see Ending a Partnership). A customer is never asked to upgrade a plan, and is never shown yours: workflows are part of the partner contract.
- You see all of them. Signed in as your own account, the same screen lists every customer’s workflows next to yours, and you can open, pause or delete any of them. Your key without a customer header does the same: the list holds every customer’s workflows, each with the id of its customer in
managedUserId. A workflow or a copy you make that way is yours, not the customer’s. - Deleting a managed user does not delete their workflows. The workflows stay in your account and keep working on every page that shows them, and only the label that said whose they were is removed. Pause or delete a customer’s workflows first when they should stop. See Deleting Managed Users.
Limits and cost
- Workflows take no credits. Making, saving and publishing one is not an AI call, so it does not use your credits and it is not counted against a customer’s allowance. Neither does starting one from a starting point: that copies what already exists and generates nothing.
- The assistant uses no credits and has a limit of its own. 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
429andRATE_LIMIT_USER_EXCEEDED, and the screen tells the customer to wait. - A workflow has up to 25 blocks.
- You can offer up to 50 starting points, and each chains at most 10 different widgets. See What can be offered.
Starting points
A starting point is a workflow of yours that your customers can copy and build on, so that they do not begin with an empty canvas: a welcome page that leads to an offer, a quiz with a result page for each answer. You build and publish it once, in your own account, offer it under a key, and your customers start from it. The screen itself always starts a new workflow blank, as the Widget Creator always opens on a blank canvas: it never lists your starting points. Offering them is for your page. List them on a page of your own, as Widgetic does with its templates, and when a customer picks one, start the copy from your server and open it in the screen withworkflowId (see Start one).
Your dashboard calls them presets. They are not the preset widgets, which are single widgets that your server hands out. A starting point can chain only widgets that you offer that way (see What can be offered).
What a customer gets
A customer who starts from one of yours gets, in their own account:- Their own copy of every widget the workflow chains: an ordinary private widget, filed under the customer, that serves the published code of yours.
- A composition of their own on each copy: a draft, with the content, design, embed settings and tables of the original.
- A draft workflow, wired like the live version of yours at that moment. It is named as the customer asks, or after the starting point.
What can be offered
A starting point is one of your own published workflows: one made in your own account (not filed under a customer, and not a team’s), that is not archived and has a live version. Because a customer gets copies, it also has to be something you are willing to give away:- Every composition in it is one you made for yourself. A composition made for a customer or for a team is not yours to give.
- It chains at most 10 different widgets, because every start copies them.
- Every one of those widgets is already one of your preset widgets. Offering a widget as a preset is how you say that it may be copied.
Offer one
Offer a workflow in your dashboard (Presets, then Workflow starting points, then Add a starting point), or from your server withPUT /partners/{partnerId}/workflow-presets/{key}:
- Sending the same key again replaces it. The call answers
200both times, so it is safe to repeat and needs noIdempotency-Key. It replaces the whole starting point: atitle,descriptionorpositionyou leave out goes back to its default. - What customers get is the live version as it is when they start. Publishing the workflow changes what the next start gets, so look at a new version before you publish it.
- Your key makes the call, or the owner of your partner, signed in on widgetic.com. An editor session cannot: it is for your server.
Read and remove
GET /partners/{partnerId}/workflow-presets lists what you offer, ordered by position and then by key. Each one says what it is made from and whether customers can start from it now:
available set to false, and unavailableReason says why: workflow_missing (the workflow was deleted), workflow_not_own, workflow_archived (unarchive it), workflow_not_published, workflow_empty, composition_not_own, too_many_widgets or widget_not_preset (a widget it chains is no longer offered as a preset). A customer is never shown one that is not available, so read this list to notice a starting point that went stale.
DELETE /partners/{partnerId}/workflow-presets/{key} stops offering it and answers { "removed": true }, or false (not an error) when nothing was offered under that key. It leaves the workflow, and every workflow a customer already started from it, alone. Deleting the workflow takes its starting point off the list too.
When an offer is refused
The reason is inerror.details.reason:
Start one
Your server starts one for a customer with two calls, made with your key and the customer’s header (see From your server): the list of what this customer is offered, which you draw on your own page, and the start itself, which makes the copies and the new draft. Then open the new workflow in the screen: give the screen itsid (the answer of the start has it) as workflowId, when you mount it or with workflows.module.setWorkflow(workflowId) on a screen that is on show.
keyis the one the list gives, andnameis optional. It is up to 120 characters. Without it, the new workflow is named after the starting point’s title.- The answer is
201with the new workflow, a draft, as for any new workflow. Itsidis theworkflowIdto open it with. - Send an
Idempotency-Key. A start takes a few seconds, because every widget is copied, and an answer lost to a timeout is then repeated and not made twice. - A start that is not offered to this customer, or can no longer be started, is
404withRESOURCE_WORKFLOW_PRESET_NOT_FOUND. The customer cannot fix it, and a half-made copy would be worse, so it reads as missing. - A start that fails leaves nothing to clean up. The answer is
503withSERVICE_UNAVAILABLEandreason: "preset_copy_failed": the compositions it made are removed again, so asking again is safe. The copies of widgets it made stay in the customer’s account as ordinary widgets, which they can delete like any other. - Your webhook is told (
workflow.created, withpresetKeyset to the key). See What you are told.
Show a workflow on a page
The screen has an Embed code button only when your page listens forshowEmbedCode at the moment it mounts, and only for a workflow that has been published. It tells your page which workflow, and your page shows the tag: the tag of the workflow’s first composition, with workflow-id added (see Show a path of compositions in one place).
A published workflow tells anyone which composition a new visitor starts on, so your page can read it without a key:
- The tag goes on a page that has the Embed SDK on it, as for any widget. The visitors on that page need no account and sign in to nothing.
- A visitor’s position stays in their own browser. See Show a path of compositions in one place for what a visitor’s browser keeps and what it tells your page.
- Counts reach the screen. What the tag reports (how many visitors reached a block or took a line) is what the customer reads in Runs.
From your server
Everything the screen does, your server can do with your API key, for one customer at a time: the same calls, on the same addresses, with the customer named in a header. SendX-Managed-User-Id (Widgetic’s id for the managed user) or X-Managed-User-External-Id (your own externalId), one of the two, and the id of your partner workspace as the workspace ($WIDGETIC_PARTNER_WORKSPACE_ID below). Everything your customers make is filed in your partner workspace, and its id is the workspaceId that the answer of an editor session carries.
xManagedUserId, or xManagedUserExternalId for your own id.
Idempotency-Key, as the reference says (see Idempotency). Saving a workflow takes the revision you read, so that two writers do not overwrite each other.
Your key reaches no more through the header than the screen does through a session:
- The customer is the one in the header, and nothing else. A body or a query that names a customer, an organization or another owner changes nothing: the workflow is filed under the customer in the header, for good.
- The customer’s workflows only. A workflow of another customer, one you made without a header, one of another account and one that does not exist all answer
404withRESOURCE_WORKFLOW_NOT_FOUND, so you cannot tell them apart. A workflow chains the compositions filed under that customer only: another composition answers404withRESOURCE_COMPOSITION_NOT_FOUND, and a draft that holds one cannot be published. - The workspace is your partner workspace. The id of another workspace answers
404withRESOURCE_WORKSPACE_NOT_FOUND, and a word where the id belongs (me, say) answers403withMANAGED_USER_SCOPE_ROUTE_NOT_AVAILABLE, as does any call that does not take the header. - The customer must be yours, and the key a partner’s. An id that is not one of your managed users, or is another partner’s, answers
404withMANAGED_USER_NOT_FOUND, and so does any API key that is not a partner’s, because only a partner has managed users. A call that is not made with an API key (a signed-in person, say) answers403withMANAGED_USER_SCOPE_NOT_ALLOWED. An empty, repeated or malformed header is400withMANAGED_USER_SCOPE_INVALID. - A customer you switched off keeps its workflows, and you can still read and change them, but you cannot make, copy or start one for it:
409withMANAGED_USER_INACTIVE. - The cost is the same. No credits (see Limits and cost).
What you are told
Your webhook can be told when a customer makes, publishes, changes or deletes a workflow, with or without the screen:
They are about your customers’ workflows only: what you make yourself, in your own account, is not told. They carry the ids and the names, and none of the workflow’s blocks, so read the workflow for what it holds now. A deleted workflow can no longer be read, so
workflow.deleted carries its name and the state it was in. A webhook that receives every event receives these too, and one that lists its events needs them added. What each one carries is in the API reference, and Events lists them all.
Errors
The screen handles these for you and tells your page (error event). The ones of the session itself are in Errors.
MANAGED_USER_SCOPE_ROUTE_NOT_AVAILABLE, MANAGED_USER_SCOPE_NOT_ALLOWED, MANAGED_USER_NOT_FOUND and MANAGED_USER_INACTIVE come only to a call made with a customer header, which your server sends with your key: the screen cannot cause them.
Next Steps
Editor Sessions
Make sessions, and what a session can do
UI Components
The SDK, tokens, the look and the language of every piece
Managed Users
File your customers’ content under them
Embed a workflow
What a workflow does on a page
Notifications
Be told when a customer makes or publishes a workflow