ByteChef Embedded, Part 11: New from Embedded Workflow Builder

On this page
In part ten a single sentence became a finished workflow, and the last step was always the same: open the result in the editor so the user can review it. Templates (part eight) and chat (part nine) end there too, and so do workflows from your custom builder when you click View workflow.
New from Embedded Workflow Builder skips the template, the agent and your own forms, and puts the user straight onto that canvas. It's for users who already think in triggers and steps, and for products that want to offer "build anything" without writing a workflow editor. In the embedded sample app it takes one POST to create the workflow and one SDK component, EmbeddedWorkflowBuilder from @bytechef/embedded, which opens it in an iframe and hands over the user's JWT by postMessage, never in the URL.
Where the Embedded Builder Fits
Open Automations in the sample app and expand the split button next to New from Template:

All five end in the same place, a workflow in the connected user's own project. What differs is who authors it: you (templates), an agent (chat and prompt), your own UI (the custom builder), or, here, the user on ByteChef's canvas with the full catalog. We compare them below; for now, know that this is the most powerful option for the user and one of the cheapest for you. You write a create call and render one component.
The Flow at a Glance
Here's the round trip in the sample app:
- The user clicks New from Embedded Workflow Builder, and a Create New Workflow dialog asks for a Label and a Description.
- Create sends
POST /api/embedded/v1/automation/workflows. ByteChef stores the workflow in the user's personal project and returns its UUID. - A green Workflow created successfully! banner appears and the list reloads, with the new workflow marked DRAFT and its toggle disabled.
- The user clicks the workflow's title, which links to
/automations/{uuid}. - That page renders
EmbeddedWorkflowBuilder, which loads ByteChef's editor in an iframe and authenticates it with the user's JWT. - The user builds, tests and publishes, then flips the toggle in the list to enable it.
Steps 1 to 3 are yours: an ordinary dialog and one fetch. Steps 5 and 6 belong to ByteChef.
Step 1: Create the Workflow
The dialog lives in src/app/automations/components/create-workflow-dialog.tsx. It's a react-hook-form dialog with a required label and an optional description:
const formSchema = z.object({
label: z.string().min(1, 'Label is required'),
description: z.string(),
});While the request runs, the submit button reads Creating.... On submit it calls createWorkflow from src/lib/api.ts:
export async function createWorkflow(payload: CreateWorkflowPayload): Promise<Response> {
return fetchWithAuth('/api/embedded/v1/automation/workflows', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
definition: `{
"label": "${payload.label}",
"description": "${payload.description}",
"triggers": [
{
"label": "Productboard",
"name": "trigger_1",
"parameters": {},
"type": "productboard/v1/newNote"
}
],
"tasks": []
}`,
}),
});
}This is the same endpoint the custom builder used in part seven. The body is {"definition": "..."}, where definition is the workflow JSON as a string. fetchWithAuth is the sample's wrapper from part one, which adds Authorization: Bearer <JWT> and the X-Environment header. On the wire:
POST /api/embedded/v1/automation/workflows
Authorization: Bearer <connected user's JWT>
X-Environment: DEVELOPMENT
Content-Type: application/json
{"definition": "{\"label\": \"Sync new notes\", \"description\": \"\", \"triggers\": [...], \"tasks\": []}"}HTTP/1.1 200 OK
Content-Type: application/json
"3f6e2a90-..."What ByteChef Does With It
ByteChef first finds or creates the user's project: one personal automation project per environment, named after their external user ID and created the first time it's needed. Templates, chat, prompt and the custom builder all write into it too.
The workflow goes in as a draft with no published version, hence the DRAFT badge and the disabled toggle. If definition is an empty string, ByteChef stores a workflow labeled New Workflow with no triggers and no tasks, and the editor shows a Manual trigger placeholder, so the user starts on a clean canvas. The response is the workflow's UUID as a JSON string, which is all the editor needs.
Three Things the Sample Does That You Shouldn't
The sample's create call is a demo shortcut. Every workflow starts with a hardcoded Productboard New Note trigger, so a user who wanted Gmail has to open the trigger's menu and pick Replace first. It builds JSON by string interpolation, so a label containing a double quote produces invalid JSON. And it throws the UUID away: the dialog only refreshes the list, leaving the user to find the new row.
A production version sends an empty definition (or a trigger that fits your product), lets JSON.stringify do the escaping, and is barely longer:
export async function createBlankWorkflow(label: string, description: string): Promise<string> {
const response = await fetchWithAuth('/api/embedded/v1/automation/workflows', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
definition: JSON.stringify({description, label, tasks: [], triggers: []}),
}),
});
if (!response.ok) {
throw new Error(`Failed to create workflow: ${response.status}`);
}
return response.json();
}const workflowUuid = await createBlankWorkflow(values.label, values.description);
router.push(`/automations/${workflowUuid}`);Now the user lands on the canvas the moment they click Create.
Step 2: Embed the Editor
The page that opens the editor, src/app/automations/[workflowUuid]/page.tsx, is the whole integration:
import {EmbeddedWorkflowBuilder} from '@bytechef/embedded';
import {getToken} from '@/lib/api';
import {BYTECHEF_APP_BASE_URL, BYTECHEF_ENVIRONMENT} from '@/lib/config';
export default async function AutomationPage({params}: {params: {workflowUuid: string}}) {
const {workflowUuid} = await params;
const jwtToken = await getToken();
return (
<EmbeddedWorkflowBuilder
baseUrl={BYTECHEF_APP_BASE_URL}
connectionDialogAllowed={true}
environment={BYTECHEF_ENVIRONMENT}
jwtToken={jwtToken}
workflowUuid={workflowUuid}
/>
);
}It's a Next.js server component that fetches the JWT from the sample's back end while rendering. The SDK's build marks the component 'use client', so no wrapper is needed.
Props
These are all the props EmbeddedWorkflowBuilder accepts in @bytechef/embedded 0.4.0:
| Prop | Type | Default | What it does |
|---|---|---|---|
jwtToken | string | (required) | The connected user's JWT. Sent to the iframe over postMessage and used for every request the editor makes |
workflowUuid | string | (required) | The workflow to open. Becomes part of the iframe URL |
baseUrl | string | 'https://app.bytechef.io' | Your ByteChef host. Self-hosted installs must set it |
environment | 'DEVELOPMENT' | 'STAGING' | 'PRODUCTION' | 'PRODUCTION' | Which environment's project, connections and settings the editor uses |
includeComponents | string[] | all components | Limits the component palette to these component names, for example ['slack', 'googleMail'] |
connectionDialogAllowed | boolean | (required) | true lets users create connections inside the editor; false limits them to existing ones. The token can still deny it (see Connections) |
That's the complete list. There are no callbacks or events (no onSave, onPublish or onClose): everything happens inside the iframe and ByteChef saves it directly. There's also no theme prop; more on that in Theming.
What It Renders
Under the hood, the component renders exactly this:
<div className="absolute inset-0 lg:pl-72">
<iframe
src={`${baseUrl}/workflow-builder.html#/embedded/builder/${workflowUuid}`}
width="100%"
height="100%"
style={{border: 'none'}}
title="Workflow Builder"
/>
</div>Two layout details matter. The iframe is 100% wide and high, so it needs a parent with a real height. And the wrapper's classes are Tailwind class names that the SDK ships no CSS for. In the sample, whose stylesheet defines them, the wrapper is absolutely positioned over the page and leaves an 18rem (pl-72) gap on large screens for the sidebar. In your app they apply only if your stylesheet happens to define the same classes, so wrap the component in a container with position: relative and an explicit height and it will fill the area you intend, whatever your CSS does.
How the Iframe Gets the User's Identity
The iframe URL carries only the workflow UUID. The JWT travels separately, through a two-message handshake.
When the editor page loads, it reads the allowed parent origins from your ByteChef server and posts {type: 'EMBED_READY'} to the parent window, addressed only to those origins (or, if none are configured, to the origin in the iframe's referrer). The SDK ignores it unless it comes from the origin of baseUrl, and replies to that origin only with {type: 'EMBED_INIT', params: {connectionDialogAllowed, environment, includeComponents, jwtToken}}. The editor accepts EMBED_INIT only from its parent window and an allowed origin, stores the token and environment for the session, and loads the workflow, showing a loading state until then.
From then on, every request the editor makes to /api/embedded/v1/, ByteChef's internal API or GraphQL carries Authorization: Bearer <JWT> and X-Environment. The editor has no ByteChef login of its own: the token is the session, scoped to one connected user in one environment, and every lookup, save, test and publish resolves the user from it and touches only that user's project.
Token Refresh
The SDK re-sends EMBED_INIT whenever its props change after the iframe is ready, so a new jwtToken is swapped in without a reload and the editor refetches its data. Every change is already saved, so the user loses nothing.
The sample doesn't use this. It fetches a token once on the server, and its back end signs tokens that live for an hour, so an editor left open longer starts failing. A small client wrapper fixes that:
'use client';
import {EmbeddedWorkflowBuilder} from '@bytechef/embedded';
import {useEffect, useState} from 'react';
export default function WorkflowEditor({initialToken, workflowUuid}: WorkflowEditorPropsI) {
const [jwtToken, setJwtToken] = useState(initialToken);
useEffect(() => {
const interval = setInterval(async () => setJwtToken(await fetchFreshToken()), 5 * 60 * 1000);
return () => clearInterval(interval);
}, []);
return (
<div style={{height: 'calc(100vh - 64px)', position: 'relative'}}>
<EmbeddedWorkflowBuilder
baseUrl={BYTECHEF_APP_BASE_URL}
environment={BYTECHEF_ENVIRONMENT}
jwtToken={jwtToken}
workflowUuid={workflowUuid}
/>
</div>
);
}fetchFreshToken is whatever calls your own token endpoint. Refresh well before the token's exp.
Lock Down Who Can Frame It
Set BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS on your ByteChef server (property bytechef.embedded.allowed-parent-origins) to the exact origins of the apps that embed the editor, comma-separated, with scheme and port and no path or wildcard:
BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS=https://app.example.com,https://admin.example.comByteChef then sends Content-Security-Policy: frame-ancestors with those origins on workflow-builder.html (and the other embeddable pages), so browsers refuse to render the editor inside any other site, and the editor accepts EMBED_INIT only from them. With an empty list any site can frame the page, and the editor logs a console warning telling you to set it.
If the editor comes up blank, check the browser console. A frame-ancestors violation means your app's origin isn't on the list. An editor stuck loading never got EMBED_INIT from an allowed origin (check http versus https and the port). And with an empty list, an app that sends Referrer-Policy: no-referrer leaves the editor no way to announce itself.
Environment and the Token
The environment prop has to agree with the token. ByteChef verifies the JWT against a signing key registered for the request's environment, and if the token carries the optional numeric environmentId claim, that must match too. A token minted for Development used with environment="PRODUCTION" is rejected. The prop defaults to PRODUCTION; the sample sets it from NEXT_PUBLIC_BYTECHEF_ENVIRONMENT, which defaults to DEVELOPMENT.
What the User Sees Inside
The editor is the canvas ByteChef's own users build with, scoped to one workflow. Here it is on a workflow from part ten:

The header has what a single-workflow editor needs and nothing more:
| Control | What it does |
|---|---|
Workflow label and V<n> DRAFT badge | The workflow's name and the version you're editing. Before the first publish it reads V1 DRAFT; after publishing V1 it reads V2 DRAFT |
| Saving... / Offline | Appears while changes save, or when the browser is offline |
| Test | Runs the workflow. Reads Chat for workflows with a chat trigger, and Stop while a run is in progress |
| Publish | Opens the Publish Project popover (more below) |
| Output (chevron icon) | Opens or closes the test-output panel |
| Settings (gear icon) | One item, Edit, to rename the workflow or change its description |
There's no project sidebar, workflow switcher or navigation to the rest of ByteChef, so the user can't leave this workflow from inside the iframe; your app owns navigation. The AI Copilot and the workflow inputs panel are also off here.
Everything else is the real editor: adding and replacing triggers, actions and flow controls (conditions, loops, branches and the rest), configuring properties, dragging data pills between steps, and the workflow issues banner and panel from part ten. Changes save as the user makes them. There's no Save button, and DRAFT in the badge tells them they're editing the draft, not what's running.
Which Components Show Up
By default the palette lists every component on your ByteChef instance plus the flow controls, not just your integrations under Embedded → Integrations, so a user can add a step for an app you never configured. Pass includeComponents to narrow it:
<EmbeddedWorkflowBuilder
// ...
includeComponents set to googleMail, slack and hubspot
/>The names are ByteChef component names, the same ones in node types like slack/v1/sendChannelMessage. Flow controls stay available either way. The sample app passes no list, so its palette offers every component:

Treat includeComponents as product design rather than a permission. It arrives from your page through postMessage, and ByteChef doesn't check saved workflows against it on the server. What users are entitled to belongs in your integration setup under Embedded → Integrations and in permission expressions.
Connections Inside the Editor
Click a step that needs an account and open its Connection tab. The dropdown lists the connections this user may use in this environment: ones they created through the ConnectDialog for your integrations, ones they created earlier inside the editor, and any a tenant admin marked as shared. The server filters the list by the JWT's user and environment, so no other user's connections ever appear.
If there's nothing to pick, a Create Connection button opens ByteChef's connection form right in the iframe, and the new connection belongs to the connected user.
Whether that button exists depends first on the connectionDialogAllowed prop: false hides connection creation. But a prop lives in your page, and a page is easy to change. For a rule the server enforces, add the optional connectionDialogAllowed claim when you sign the JWT:
const token = jwt.sign(
{
connectionDialogAllowed: false,
sub: externalUserId,
},
privateKey,
{algorithm: 'RS256', expiresIn: '10m', keyid: signingKeyId}
);If the claim is missing or true, users can create connections in the editor. If it's false, the editor offers only existing connections, and ByteChef rejects any attempt to create one through the API with 403, whatever the page sends. If it isn't a boolean, the token is invalid.
They combine in one direction only: a false prop hides creation even when the token allows it, but a true prop can't override a token that says false. The sample passes connectionDialogAllowed={true} and its tokens don't carry the claim, so its users can create connections. Its back end does accept a customClaims object in the POST /api/token body, so you can try the claim without changing code. Note that the claim is per token, not per component; to allow connection creation in one surface but not another, mint a separate token for each.
Testing
Test runs the current draft with the connections chosen on each step, and the output panel opens with the result of every step. It's disabled until the workflow can run, with a tooltip that says why, for example Add at least one task. or Pick a Slack connection for "Post to #sales". During a run it becomes Stop.
Test runs are real calls: a test that sends a Slack message sends one from the user's account. That's what makes the test trustworthy, and it's worth saying in your onboarding.
Publishing
Publish opens a popover titled Publish Project with an optional Description of up to 256 characters (the placeholder suggests something like Added a Slack notification for new leads):

Submitting it freezes the current definition as the next version (V1, then V2, and so on), deploys that version for the user together with the connection chosen on each step in this environment, and shows the toast The workflow has been published. It's the same operation as POST /api/embedded/v1/automation/workflows/{uuid}/publish from part seven, done from inside the editor. Afterwards the user keeps editing a new draft, and nothing they change reaches the running workflow until they publish again.
Enabling Happens Outside the Editor
The editor has no on/off switch. Turning a published workflow on is your app's job, with the same call as in parts seven through ten:
// Turn it on (DELETE to turn it off)
const response = await fetchWithAuth(`/api/embedded/v1/automation/workflows/${workflowUuid}/enable`, {
method: 'POST',
});The sample's toggle on the Automations list makes this call and stays disabled until the workflow has a version. ByteChef validates the workflow first: if the published version has validation errors (a step without a required connection, for example), the call fails with 409 and a body like {"invalidWorkflowErrorCount": 2}, which the sample shows as Could not enable the workflow: it has 2 validation error(s). Fix them in the workflow, then enable it again. Enabling a workflow that was never published fails too, so publish first.
That split is deliberate. Where an automation is turned on and what you show next to it (last run, error count, owner) are product decisions, and they belong in your list.
Theming: What You Can and Can't Change
EmbeddedWorkflowBuilder has no theme prop. The standalone editor renders ByteChef's default light appearance, and your page's CSS can't reach inside the iframe.
You do control placement: the editor sits wherever you put it, at whatever size you give it. Your users never navigate to a ByteChef URL, and there's no ByteChef chrome around the canvas. You also control the catalog through includeComponents. You don't control colors, fonts or copy. Labels are English, component documentation links point at ByteChef's docs, and any webhook URL a trigger shows is on your ByteChef host's domain.
If you need your brand colors, the Automation Hub (next part) takes a theme and applies it to the same editor. For a standalone page, design the surrounding layout so the neutral light look reads as a panel of your product rather than a foreign page.
Embedded Builder vs. the Other Four
Every create option produces the same kind of workflow, and every one can end up in this editor. They differ in what you build and what the user does:
| Embedded Workflow Builder | Custom Builder (part 7) | Template (part 8) | Chat (part 9) | Prompt (part 10) | |
|---|---|---|---|---|---|
| Who authors the steps | The user, on ByteChef's canvas | The user, in your forms | You, ahead of time | ByteChef's agent, with the user | ByteChef's agent, alone |
| UI you build | A create dialog and a page | The whole editor and its JSON | A gallery | A chat page (copied component) | A form |
| What the user can build | Anything in the palette | Only what your catalog offers | Only your templates | What the agent builds from your enabled integrations | What the agent builds from your enabled integrations |
| Requires an AI provider | No | No | No | Yes | Yes |
| Connections | Picked or created in the editor | Bound by your code via REST | Bound after copying | Picked or connected in the thread | Picked in the editor afterwards |
| Best for | Power users | Opinionated, narrow products | Common, known automations | Fuzzy requests | Clear, short requests |
The embedded and custom builders sit at opposite ends of one choice. The custom builder keeps ByteChef behind the REST API and gives you every pixel, but you write the editor. The embedded builder gives you the full editor for free, but you accept its look and its full power. Many products ship both: a simple custom form for common cases, and an Advanced link that opens the same workflow in the embedded builder.
It's also where the other three hand off. A template copy, a chat-built draft and a generated workflow all need a review before they're published, and this component is that review step, so if you adopt any of parts eight to ten, you already need this page.
Server-to-Server Variant
The create call also exists for your back end: POST /api/embedded/v1/{externalUserId}/automation/workflows, authenticated with your environment's API key instead of the user's JWT, with the same {definition} body and UUID response. Use it to prepare a workflow before the user arrives, such as a starter automation during onboarding, then open it with EmbeddedWorkflowBuilder and the user's token. The editor itself always runs with the connected user's JWT.
Hardening the Demo for Production
The sample proves the round trip. Before your users get it, close these gaps:
- Create a real blank workflow instead of the hardcoded Productboard trigger, or start with a trigger that fits your product.
- Build the definition with
JSON.stringify, never by interpolating user input. - Navigate to the editor with the returned UUID instead of refreshing a list.
- Size the container yourself with a positioned element and an explicit height.
- Pass a fresh
jwtTokenbefore the old one expires; the SDK forwards it without a reload. - Set
BYTECHEF_EMBEDDED_ALLOWED_PARENT_ORIGINS, or any site can frame the editor (and every console shows the warning). - Set
environmentexplicitly to match the token, since its default isPRODUCTION. - Pass
includeComponentsso the palette offers the apps your product supports. - Sign
connectionDialogAllowed: falsefor users who may only use connections you or their admins provide, and set the prop to match so the UI doesn't offer what the server will refuse. - Show the
409validation count with a link back to the editor, and keep the toggle disabled until the workflow has a version. - Tell users that test runs call the real apps with their real accounts.
What You Own, What ByteChef Owns
You own the entry point and create dialog, the page and container, token minting and refresh, the environment, which components the palette offers, whether users may create connections (through the claim), the workflow list, enabling and disabling, and the allowed parent origins.
ByteChef owns the editor itself (canvas, palette, properties, data pills, flow controls and validation), the connection picker and form, test runs and their output, autosave, versioning and publishing, the per-user project, and the engine that runs every published workflow.
So this option moves the most UI to ByteChef for the least code on your side: a dialog, one fetch and one component. The most expensive piece of any iPaaS, the visual editor, becomes a dependency you keep current with npm update.
What's Next
So far you've built the surrounding experience yourself: the list, the toggles, the gallery, the buttons. The next part, The Automation Hub, flips that around with one embedded component that renders a complete end-user automation page, with your template catalog, the user's connections and this same builder inside it, themed to match your product.
Eleven Parts In
Here's the series so far:
- Connect your users' apps (the JWT and ConnectDialog everything rests on).
- Act on those connected apps directly with the ComponentKit.
- Chat with an AI assistant that uses the ComponentKit's tools.
- Trigger their workflows from your product's events.
- Call a workflow like a synchronous API.
- Agent over MCP: the same tools, discovered through an open protocol.
- Author workflows in a builder you designed yourself.
- Start from a template you curated.
- Talk a workflow into existence with ByteChef's agent.
- Describe it in one sentence and get a finished workflow back.
- Build it on ByteChef's own canvas, embedded in your product (this part).
Parts seven through eleven are five ways to create the same thing, a real ByteChef workflow in the user's own project: your own builder gives you the most control, templates the most curation, chat and prompt the least effort, and the embedded builder the most power. They combine freely, and this editor is where most of them meet.
Following along? Run the embedded sample app, open Automations → New from Embedded Workflow Builder, give the workflow a label and click Create. Then click its title, replace the trigger with one of your connected apps, add a step, click Test, and Publish it.
Subscribe to the ByteChef Newsletter
Get the latest guides on complex automation, AI agents, and visual workflow best practices delivered to your inbox.


