ByteChef LogoByteChef
EmbeddedInitial Setup

Displaying the Connect Dialog

Open the hosted Connect dialog from your app so end users can authorize integrations and enable workflows.

The Connect dialog is the embedded surface where an end user connects an integration. It walks them through authorizing the third-party account (OAuth consent or API key entry), enabling the integration's workflows and filling in workflow inputs. It stores the resulting credentials as a Connection under the user's Connected User record. ByteChef stores and refreshes the tokens; your application never handles them.

The dialog renders in your page (not in an iframe), opened by the useConnectDialog hook.

Activate the integration

The dialog only offers integrations that are live in the target environment:

  • The integration has a published version.
  • A configuration for that version exists in the environment and is turned on.

Both steps are covered in Adding an Integration.

Display the Connect dialog in your app

Your backend must be able to mint an end-user JWT. See Installing the SDK. Pass the token and the integration's id to useConnectDialog:

'use client';
import {useConnectDialog} from '@bytechef/embedded';

export function ConnectGmailButton({jwtToken, integrationId}: {
    jwtToken: string;
    integrationId: string;
}) {
    const {openDialog} = useConnectDialog({
        baseUrl: 'https://your-bytechef-host.example.com',
        environment: 'DEVELOPMENT',
        integrationId,
        jwtToken,
    });

    return <button onClick={openDialog}>Connect Gmail</button>;
}

For a ready-made catalog, use the Integration Marketplace component, which opens this dialog in your page.

To build an integrations catalog yourself, and to get each integrationId, list the integrations available to the current user from the embedded API:

const response = await fetch(`${baseUrl}/api/embedded/v1/integrations`, {
    headers: {
        'Authorization': `Bearer ${jwtToken}`,
        'X-Environment': 'DEVELOPMENT',
    },
});

const integrations = await response.json();

Each returned integration includes id, name, componentName, description, icon, integrationVersion, multipleInstances and the user's existing integrationInstances, so you can render "Connect" and "Connected" states. The Sample App implements this page.

For an integration the user already connected, pass the instance's id as integrationInstanceId together with integrationId. The dialog then opens in the workflows view for that instance, where the user turns workflows on or off and edits inputs, instead of the first-time connect flow.

When one of your MCP Servers exposes tools for the integration, the manage view also shows a Tools tab. There the user enables the tools their AI agent may call. Tools start disabled.

To react when the dialog closes, for example to refresh your integrations list, pass onClose. It runs whenever the dialog closes. If the integration fails to load, the dialog stays open and shows the error, and onClose runs when the user closes it:

const {openDialog} = useConnectDialog({
    baseUrl: 'https://your-bytechef-host.example.com',
    environment: 'DEVELOPMENT',
    integrationId,
    jwtToken,
    onClose: () => refetchIntegrations(),
});

To match a dark host page, pass mode: 'dark'. It switches the dialog's surfaces, borders and text to a dark palette. The default is 'light'. For finer control, set the --bytechef-dialog-* CSS variables described in Theming and Localization:

const {openDialog} = useConnectDialog({
    baseUrl: 'https://your-bytechef-host.example.com',
    environment: 'DEVELOPMENT',
    integrationId,
    jwtToken,
    mode: 'dark',
});

Connection-only and reconnect modes

Two optional modes narrow what the dialog does. They are exclusive: pass one or neither, and TypeScript rejects connectionOnly together with reauthorizeConnectionId, and each callback outside its mode.

  • connectionOnly: true with onConnected(integrationInstanceId, connectionId). The dialog closes as soon as the integration instance exists, instead of continuing to the workflows view. If the user already has an instance with valid credentials, onConnected runs at once without showing the dialog; pass newConnection: true to create another instance anyway. If the existing instance's credentials are invalid, the user reconnects first. In this mode onClose also runs after onConnected, whether the connection already existed or was just created.
  • reauthorizeConnectionId with onReauthorized(connectionId). The dialog shows the connection form for that existing connection and replaces its credentials.
const {openDialog} = useConnectDialog({
    baseUrl: 'https://your-bytechef-host.example.com',
    environment: 'DEVELOPMENT',
    integrationId,
    jwtToken,
    onReauthorized: (connectionId) => refetchConnections(),
    reauthorizeConnectionId: connectionId,
});

Only one Connect dialog renders per page. Do not keep a useConnectDialog instance mounted while the activation dialog's Connect is in use.

Props

PropTypeDefaultDescription
baseUrlstringhttps://app.bytechef.ioURL of your ByteChef instance.
environmentstring'PRODUCTION'DEVELOPMENT, STAGING or PRODUCTION.
integrationIdstring-Id of the integration to connect. Required.
integrationInstanceIdstring-Opens the workflows view of an existing instance.
toolsOnlybooleanfalseIn the workflows view, shows only the integration's MCP tools, without the Workflows tab.
jwtTokenstring-End-user JWT. Required.
mapObjectFieldsMapObjectFieldsType-Enables the Field Mapping step.
mode'dark' | 'light''light'Color palette of the dialog.
onClose() => void-Runs whenever the dialog closes.
connectionOnlybooleanfalseCloses the dialog once the integration instance exists.
newConnectionbooleanfalseWith connectionOnly, creates a new instance even if one with valid credentials exists.
onConnected(integrationInstanceId: number, connectionId: number | undefined) => void-With connectionOnly, runs once the instance exists.
reauthorizeConnectionIdnumber-Opens the connection form for an existing connection and replaces its credentials.
onReauthorized(connectionId: number) => void-With reauthorizeConnectionId, runs after the credentials are replaced.

The hook returns openDialog and closeDialog.

The dialog can collect more than credentials

Beyond the account authorization step, the dialog renders any end-user-facing workflow inputs (including live dropdowns fetched against the user's new connection) and, when configured, a Field Mapping step where the user maps your application's fields to the integration's fields.

Authenticating an account

When the user clicks your button, the dialog opens and the flow depends on the component's authorization type:

  • OAuth 2.0 - the user is sent to the provider's consent screen (branded as your developer app) and returns with an authorized connection.
  • API key / other credentials - the dialog renders the component's credential form and validates the entry.

Either way, the credential is stored server-side as a Connection scoped to the Connected User identified by the JWT's sub claim, in the environment the dialog was opened with.

Verify the connection

After a user connects, check the result in the ByteChef UI:

  • Embedded → Connected Users - the user appears in the list. Open the user to see, on the Integrations tab, the connected integration, its credential status and its enabled workflows. Connections owned by connected users are not listed on Embedded → Connections, which shows only admin-created connections.
  • Embedded → Workflow Executions - runs of the integration's workflows as they start firing.

Next steps

  • Trigger the user's workflows from your product with App Events.
  • Let users author their own automations with the embedded workflow builder - see the Quick Start.

How is this guide?

Last updated on

On this page