ByteChef LogoByteChef
EmbeddedWorkflows

Field Mapping

Let end users map their application's fields to a connected integration's fields inside the Connect dialog.

Field Mapping lets your end user, inside the Connect dialog, pick a remote object type (for example Contacts or Leads) and map your application's fields to the connected integration's fields. The result is saved as a workflow input value, which workflow steps can read as a data pill or apply with the Field Mapping component. Workflow authors declare the input; end users fill it in.

Two halves make up the feature, joined by a single shared object name:

  • Design time (the workflow author) - declare a field_mapping workflow input with an objectName in the workflow definition.
  • Runtime (the end user) - the React SDK renders the mapping UI and fetches object types and integration fields from the user's connection through callbacks you pass to useConnectDialog.

Key Features

FeatureDescription
Object-type selectorThe user picks a remote object type; the integration-field dropdown then loads for that type.
Live option listsObject types and integration fields are fetched at runtime from the user's connection, not hardcoded.
Configurable rowsdefaultFields seeds which application-field rows show initially; userCanRemoveMappings lets users remove and re-add them.
User-creatable fieldsWhen your application object supports freeform fields or a flexible schema, userCanCreateFields lets users create their own fields beyond your configured set.
Object nameThe input's objectName is the key your runtime mapObjectFields config must use.

Scope

Included: dynamic application fields, the object-type selector, flat (non-paginated) option lists, configurable and user-creatable mappings, and the Field Mapping component's Map to Integration Object and Map to Application Object actions. Not included: paginated or search-as-you-type dropdowns, and an automatic "apply field mapping" toggle on triggers.

Declared in the definition, not in the input dialog

The workflow editor's input dialog offers only the scalar types (Boolean, Date, Date Time, Integer, Number, String, Time) and has no Field Mapping type. Declare a field-mapping input in the workflow definition: write it in a .json or .yaml file and bring it in with Import Workflow, or export, edit and re-import an existing workflow.


How it fits together

Design time (workflow definition)
  input  type = "field_mapping"
    └─ objectName  → matches the SDK config key

Runtime (end user, Connect dialog)
  useConnectDialog({ mapObjectFields: { <objectName>: { objectTypes, integrationFields, applicationFields: { fields, ... } } } })
    object-type <select>     ← objectTypes.get({ executeAction, search })
    row: app field → integration field <select> ← integrationFields.get({ executeAction, objectType, search })
    executeAction(...)       → runs a component action against the user's live credentials
    mapping value            → saved via the debounced inputs PUT

The same object name keys both sides: the input's objectName must equal the key in the runtime mapObjectFields config.


Design time: declare a field-mapping input

In the workflow definition, give the input type: field_mapping and an objectName. The other input fields are the usual ones:

{
  "inputs": [
    {
      "name": "contactMapping",
      "label": "Contact Mapping",
      "type": "field_mapping",
      "required": false,
      "objectName": "Contacts"
    }
  ]
}

objectName is the only design-time value the runtime needs: the SDK looks up your mapObjectFields config under exactly that key. The option lists are not authored here; the callbacks in the next section fetch them at runtime.

Import the definition with Import Workflow (from the integration's three-dot menu or the editor's settings menu), then publish as usual.

The test value and sampleMapping

The input's test value is a static sample of what the SDK fetches at runtime: the object types, integration fields and application fields, keyed by the object name. Add a sampleMapping (a value of the same shape the Connect dialog saves) so the Field Mapping actions can run from the editor's Test button, which has no connected user to read a real mapping from. Without it, the action fails with Add a sampleMapping to the '<input>' input's test value to run this action from the editor:

{
  "Contacts": {
    "objectTypes": [{"label": "Contacts", "value": "contacts"}],
    "integrationFields": [{"label": "First Name", "value": "first_name"}],
    "applicationFields": {"fields": [{"label": "Title", "value": "title"}]},
    "sampleMapping": {
      "objectType": "contacts",
      "mappings": [
        {"applicationField": {"label": "Title", "value": "title", "custom": false}, "integrationField": "first_name"}
      ]
    }
  }
}

Runtime: configure the SDK

Pass mapObjectFields to useConnectDialog (or to the IntegrationMarketplace component), keyed by the same object name as the input's objectName. Each entry supplies two get callbacks plus the application fields and optional toggles:

'use client';
import {
    useConnectDialog,
    type MapObjectFieldsType,
    type OptionType,
} from '@bytechef/embedded';

const mapObjectFields: MapObjectFieldsType = {
    Contacts: {
        // Remote object types - fetched live against the user's connection.
        objectTypes: {
            get: async ({executeAction}) => {
                const objects = await executeAction('hubspot', 1, 'listObjects', {});

                return objects.map((object: any): OptionType => ({label: object.name, value: object.id}));
            },
        },
        // Integration fields for the chosen object type.
        integrationFields: {
            get: async ({executeAction, objectType}) => {
                const fields = await executeAction('hubspot', 1, 'listObjectFields', {objectType});

                return fields.map((field: any): OptionType => ({label: field.label, value: field.id}));
            },
        },
        // Your application's fields the user maps from (the left column).
        applicationFields: {
            fields: [
                {label: 'Title', value: 'title'},
                {label: 'Email', value: 'email'},
            ],
            defaultFields: [],            // [] = none shown initially; omit = all shown
            userCanRemoveMappings: true,  // optional - per-row remove / re-add
            userCanCreateFields: true,    // optional - let users invent a field
        },
    },
};

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

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

The executeAction helper

Both callbacks receive an executeAction function provided by the SDK:

executeAction(componentName: string, componentVersion: number, actionName: string, input: Record<string, unknown>): Promise<unknown[]>

It runs the named component action against the connected user's stored credentials and returns the action's result array. It is bound to the current dialog's integration instance (sent as the X-Instance-Id header) and the user's JWT, so:

  • You never thread an instance id through your callbacks.
  • A callback cannot target another user's instance: the server verifies that the connected user (from the JWT sub) owns the instance and rejects the call otherwise.

Callback arguments

CallbackArgumentNotes
objectTypes.get{executeAction, search?}search is accepted but unused (no server-side search).
integrationFields.get{executeAction, objectType, search?}The integration-field <select> stays disabled until an object type is chosen.

Config reference

FieldTypeRequiredDescription
objectTypes.get(args) => Promise<OptionType[]>yesReturns the remote object types for the selector.
integrationFields.get(args) => Promise<OptionType[]>yesReturns the integration fields for the chosen object type.
applicationFieldsobjectyesNested object containing your application's field options and toggles (see sub-fields below).
applicationFields.fieldsOptionType[]yesYour application's fields (the mappable left column).
applicationFields.defaultFieldsstring[]novalues of the rows visible initially. [] shows none; omitting shows all.
applicationFields.userCanRemoveMappingsbooleannoAllow per-row remove and re-add.
applicationFields.userCanCreateFieldsbooleannoFor application objects with a freeform or flexible schema, let users create their own application fields beyond the configured fields.

OptionType is {label: string; value: string}.


The stored value

The user's mapping is saved as the workflow input's value, through the same debounced inputs PUT the Connect dialog uses for other inputs. Each row carries the application field's label and a custom flag, so user-created fields are kept:

{
  "objectType": "contacts",
  "mappings": [
    {"applicationField": {"label": "Title", "value": "title", "custom": false}, "integrationField": "first_name"},
    {"applicationField": {"label": "Priority", "value": "priority", "custom": true}, "integrationField": "hs_priority"}
  ]
}

This is exported as FieldMappingValueType from @bytechef/embedded.

Applying the mapping in a workflow

Add the Field Mapping component to the workflow. Its two actions take the input's Object Name, an Input Type and the Data, and read the connected user's saved mapping themselves, so you do not pass the mapping value in:

ActionTurnsIntoUse it when
Map to Integration Objectyour application's object ({title, email})the integration's fields ({first_name, hs_email})writing your data into the user's CRM
Map to Application Objectan integration record ({first_name, hs_email})your application's fields ({title, email})handing a CRM record back to your app

Both accept a single object or an array (set Input Type to Object or Array). Keys that no mapping covers are dropped unless Include Unmapped is on; a missing source key is omitted rather than written as null.

From a Script step, call the same actions through the component proxy, in JavaScript or Python:

function perform(input, context) {
    const mapped = context.component.fieldMapping.mapToApplication({
        objectName: "Contacts",
        inputType: "ARRAY",
        data: input.records
    });

    return mapped.filter((record) => record.email);
}

The saved mapping is also readable as a plain data pill, ${input.contactMapping}, for a step that inspects it instead of applying it.


Example use case

You sync your app's contacts to whichever CRM each customer connects. You declare one field_mapping input with the object name Contacts. At runtime, objectTypes.get lists the CRM's object types and integrationFields.get lists the fields of the chosen one, both through executeAction with that user's credentials. The user maps your Title and Email fields to the CRM's fields and optionally adds a custom field. The sync workflow's Map to Integration Object step then turns each of your contacts into the CRM's shape before the upsert.

How is this guide?

Last updated on

On this page