ByteChef LogoByteChef
SettingsComponents
Enterprise Edition

Custom Components

Extend the component catalog with your own components - a JavaScript or Python source file written in ByteChef or uploaded, or a Java jar - with drafts, publishing, versions and an API for CI deploys.

A component is ByteChef's unit of integration: a bundle of actions, triggers and a connection definition that wraps one external system or capability. When the built-in catalog does not cover what you need, you write a custom component. Once published it appears in the workflow editor next to the built-in components, with its own typed properties, output schema, connection type and triggers.

Availability

Custom components are an Enterprise Edition feature. Settings → Custom Components is shown when the ff-1024 feature flag is on and is open to the ADMIN and USER authorities. Creating, importing, editing the source of and publishing a component require ADMIN. API Connectors is a separate entry behind its own ff-207 flag.


When to write a custom component

ByteChef gives you four ways to add your own logic. Pick the lightest one that fits.

You needUse
A few lines of logic used in one workflowA Script step
A whole workflow, or a project of workflows, kept in GitA code workflow
A REST API with an OpenAPI specification and no custom logicAn API connector
A reusable integration with its own schema, connection, triggers or AI toolsA custom component

A custom component is worth the extra structure when:

  • It is reused across many workflows. Define it once and every workflow picks it from the catalog.
  • It has a meaningful schema. Declared properties and outputs give the editor typed inputs, validation and data pills for downstream steps.
  • It authenticates. A declared connection plugs into encrypted credential storage, the Connections page and the platform's OAuth2 flow.
  • It starts workflows. Polling and webhook triggers are only available in components.
  • An AI agent should call it. An action marked as a tool becomes an AI agent tool.

A code workflow and a custom component do different jobs. A code workflow is a workflow: it calls components. A custom component is a building block: workflows, including code workflows, call it. A script custom component cannot call other components.

Languages and artifacts

The language comes from the file extension.

LanguageArtifactExtensionCreate in ByteChefEdit source in ByteChef
JavaScriptone source file.jsYesYes
Pythonone source file.pyNo, upload onlyYes
Javajar.jarNo, upload onlyNo

JavaScript and Python components run in the GraalVM polyglot sandbox. Java components run in the server JVM behind an isolating class loader. An administrator can turn off Java uploads; see Restricting Java uploads.

Ruby (.rb) is recognized by the language detection but uploads are rejected with LANGUAGE_NOT_SUPPORTED. Any other extension is rejected as an unsupported language.

Sample repositories

There is no Python sample repository. The Python example below shows the same contract in Python. Sample Repositories lists every ByteChef sample.


Identity, versions and status

A custom component is identified by its name and its version, both declared in the component itself. Each version is a separate row in the list, and workflows pin the version they use: publishing version 2 does not change what a workflow bound to version 1 runs. In a workflow, an action is referenced as <name>/v<version>/<actionName>, for example sampleCustomComponentJavaScript/v1/sampleAction1.

Each version has a status:

StatusEditable in ByteChefVisible to workflows
DraftYesNo
PublishedNo: saving a change starts a new draft versionYes

and an enabled switch. A disabled component is left out of the component catalog, so it cannot be added to new steps. Steps that already reference that name and version keep resolving it.

There is at most one draft per component name.


The script contract

This section applies to JavaScript and Python components. For Java, see The Java contract.

The file

A script component is one file. ByteChef evaluates it and reads the value it evaluates to:

  • JavaScript: the file's completion value is the definition, usually one parenthesized object expression, ({ ... }). Do not use export, module.exports or a bundler: they hide the object from the server.
  • Python: the file's last expression is the definition, a types.SimpleNamespace. Define your functions with def above it. The members inside it (actions, properties, connection) are ordinary dicts and lists.

ByteChef evaluates the file again for every call: loading the definition, each action run, each trigger poll or webhook request, each options lookup. Top-level code should only build the definition. Nothing you store in a variable survives from one call to the next; a polling trigger carries its state in closureParameters instead.

Component

MemberTypeRequired
namestringYesThe component's identity. Cannot change once the component exists. A letter followed by letters and digits (camelCase, for example acmeTasks), at most 128 characters, and not the name of a built-in component.
versionintegerYesThe component version.
titlestringNoShown in the catalog and the list.
descriptionstringNo
iconstringNoAn inline SVG, shown in lists and on the canvas.
connectionobjectNoSee Connections.
actionslist of actionsNoSee Actions.
triggerslist of triggersNoSee Triggers.

Actions

MemberTypeRequired
namestringYesUnique within the component. A letter followed by letters and digits, for example createTask. Trigger names follow the same rule.
performfunctionYesCalled as perform(input, connection, context). Its return value is the action's output.
titlestringNo
descriptionstringNoFor a tool, the text the model reads.
propertieslist of propertiesNoThe action's inputs. See Properties.
outputpropertyNoThe output schema. See Output.
sampleOutputanyNoA sample of the output.
toolbooleanNotrue also exposes the action as an AI agent tool. See Tools.

The perform function

perform(input, connection, context) receives three arguments, named like the Script component's:

ArgumentHolds
inputThe values the step configured for the action's properties, keyed by property name. Empty when the action declares none.
connectionThe parameters of the connection selected for the step, keyed by connection property name (for OAuth2, the platform's token values such as access_token). Empty when no connection is configured.
contextTwo functions: context.http(request) and context.log(level, message).

Return any JSON-like value: an object, a list, a string, a number, a boolean or null. It becomes the step's output.

In JavaScript, a perform that declares fewer parameters still works, because JavaScript ignores extra arguments. In Python, declare all three.

context.http

context.http(request) executes an HTTP request through the platform's HTTP client, the same client built-in components use, so the selected connection's authorization (for example the bearer token or API key header) is applied to the request unless you turn it off. It returns {statusCode, headers, body}.

Request memberRequired
urlYesThe full URL.
methodYesGET, POST, PUT, PATCH, DELETE or HEAD.
headersNo{name: value}. A value is a string or a list of strings.
queryParametersNoSame shape as headers.
bodyNoA wrapper around the payload, {content, contentType, mimeType}. See below.
configurationNoRequest options. See below.

body is not the payload itself. contentType is required and is one of JSON, FORM_URL_ENCODED, FORM_DATA, RAW or XML. mimeType applies to RAW and XML only. BINARY bodies are not supported in the sandbox and fail when the action runs.

body: {content: {id: 1}, contentType: "JSON"}
body: {content: "a,b\n1,2", contentType: "RAW", mimeType: "text/csv"}

configuration takes timeoutMillis (a number), responseType (JSON, TEXT, XML or BINARY), and the booleans followRedirect, followAllRedirects, allowUnauthorizedCerts and disableAuthorization.

const response = context.http({
    url: "https://api.example.com/items",
    method: "POST",
    body: {content: {name: "widget"}, contentType: "JSON"},
    configuration: {timeoutMillis: 10000, responseType: "JSON"}
});

return response.body;

Enumerated values are resolved by name on the server, so they are case sensitive. A lowercase "get" or a contentType of "application/json" fails when the action runs, not when the component is saved.

context.log

context.log(level, message) writes a line to the step's execution log. level is TRACE, DEBUG, INFO, WARN or ERROR, in any case ("warn" and "WARN" are the same level). Any other value, or no level, is logged at INFO.

context.log("WARN", "item " + input.itemId + " has no owner");

console.log in JavaScript and print in Python do not reach the execution log. They go to the server log, prefixed with [guest].

Properties

Actions, triggers and connections declare their inputs as a list of properties, each an object with a name and a type.

TypeType-specific members
STRINGminLength, maxLength, regex, defaultValue, options, controlType
INTEGERminValue, maxValue, defaultValue, options
NUMBERminValue, maxValue, defaultValue, options
BOOLEANdefaultValue
DATE, DATE_TIME, TIME
OBJECTproperties, additionalProperties (lists of properties)
ARRAYitems (a list of properties), minItems, maxItems, multipleValues
FILE_ENTRY
NULL
DYNAMIC_PROPERTIESproperties (a function), propertiesLookupDependsOn. Actions only; see Dynamic properties.

Every type also takes label, description, placeholder, required, advancedOption, hidden, expressionEnabled and displayCondition. controlType is the name of an editor control, such as TEXT_AREA, PASSWORD, EMAIL or URL, and applies to STRING properties. optionsLookupDependsOn lists the names of the properties whose values an options function reads.

Static options are a list of {label, value} entries whose values match the property's type:

{
    name: "priority",
    type: "STRING",
    label: "Priority",
    options: [
        {label: "Low", value: "low"},
        {label: "High", value: "high"}
    ],
    defaultValue: "low"
}

An unknown type fails the load with Unsupported property type.

Dynamic options

On an action property of type STRING, INTEGER or NUMBER, options can be a function. The editor calls it when the user opens the dropdown, so the choices can depend on the other inputs and on the selected connection:

{
    name: "projectId",
    type: "STRING",
    label: "Project",
    required: true,
    options: function (input, connection, searchText) {
        return [
            {label: "Website", value: "p-1"},
            {label: "Mobile App", value: "p-2"}
        ];
    }
}

The function receives the action's current input values, the selected connection's parameters and the search text the user typed (or null). It returns a list of {label, value} entries, or a list of plain values, each used as both label and value. Values are passed to the editor as strings. To re-run the lookup when another field changes, list that field in optionsLookupDependsOn.

Dynamic properties

A property of type DYNAMIC_PROPERTIES stands for a set of properties computed at edit time, for example the fields of a record type the user picked:

{
    name: "fields",
    type: "DYNAMIC_PROPERTIES",
    propertiesLookupDependsOn: ["recordType"],
    properties: function (input, connection) {
        if (input.recordType === "contact") {
            return [
                {name: "email", type: "STRING", label: "Email", required: true},
                {name: "phone", type: "STRING", label: "Phone"}
            ];
        }

        return [{name: "title", type: "STRING", label: "Title"}];
    }
}

The function receives the action's current input values and the connection's parameters, and returns a list of properties in the same shape as a static properties list. It must not return another DYNAMIC_PROPERTIES property.

Dynamic options and dynamic properties are supported on action properties. Trigger and connection properties are static.

Output

Without an output declaration an action publishes no schema, and downstream steps have no data pills to pick from. Declare output as a property, usually an OBJECT with nested properties, and optionally a sampleOutput:

{
    name: "getItem",
    properties: [{name: "itemId", type: "STRING", required: true}],
    output: {
        type: "OBJECT",
        properties: [
            {name: "id", type: "STRING"},
            {name: "name", type: "STRING"}
        ]
    },
    sampleOutput: {id: "42", name: "Widget"},
    perform: function (input, connection, context) { /* ... */ }
}

A sampleOutput without an output is accepted too. Triggers take the same two members.

Tools

An action with tool: true is also registered as a TOOLS cluster element, so an AI agent can call it. It stays available as a normal action. The model decides when to call the tool from its description, so write the description for the model:

{
    name: "lookupCustomer",
    title: "Lookup Customer",
    description: "Finds a customer by their email address and returns the customer's id.",
    tool: true,
    properties: [{name: "email", type: "STRING", required: true}],
    output: {type: "OBJECT", properties: [{name: "id", type: "STRING"}]},
    perform: function (input, connection, context) { /* ... */ }
}

Triggers

A trigger has a name, a type and, optionally, title, description, properties, output and sampleOutput. Three types are supported. A trigger without a type is a POLLING trigger.

TypeFunctionsFires when
POLLINGpollThe scheduled poll returns records.
STATIC_WEBHOOKwebhookRequestA request reaches the workflow's webhook URL, which you register with the provider yourself.
DYNAMIC_WEBHOOKwebhookEnable, webhookDisable, webhookRequestA request reaches the webhook URL the trigger registered with the provider when the workflow was enabled.

LISTENER triggers are rejected when the component loads: a listener holds a live connection open, and a script that is evaluated per call has nowhere to keep it.

Polling triggers

poll(input, connection, closureParameters) is called on a schedule. closureParameters holds what the previous poll returned, empty on the first poll. Return {records, closureParameters, pollImmediately}:

  • records: a list. Each record starts one workflow run.
  • closureParameters: an object handed to the next poll. Use it for a cursor or a last-seen timestamp.
  • pollImmediately: true polls again right away instead of waiting for the next scheduled poll, for paging through a backlog.
triggers: [
    {
        name: "newItem",
        title: "New Item",
        type: "POLLING",
        properties: [{name: "folder", type: "STRING", required: true}],
        output: {type: "OBJECT", properties: [{name: "id", type: "STRING"}]},
        poll: function (input, connection, closureParameters) {
            const since = closureParameters.cursor || 0;

            const items = [{id: "1", createdAt: since + 1}];

            return {records: items, closureParameters: {cursor: since + 1}};
        }
    }
]

Every function gets a context

The same context that perform receives is passed as the last argument to the other functions too: trigger functions (poll(input, connection, closureParameters, context), webhookRequest, webhookEnable, webhookDisable), options functions (options(input, connection, searchText, context)), dynamic properties functions (properties(input, connection, context)) and connection URL and apply functions (tokenUrl(connection, context)). A polling trigger can call the provider's API with context.http, and a DYNAMIC_WEBHOOK trigger's webhookEnable can register the URL with it. The argument is optional: a function that does not declare it is called without it, in Python as well as in JavaScript.

Static webhook triggers

webhookRequest(input, connection, request) is called for each request that reaches the workflow's webhook URL. request is {headers, parameters, body, method}, and the return value becomes the trigger's output:

{
    name: "onPush",
    title: "On Push",
    type: "STATIC_WEBHOOK",
    webhookRequest: function (input, connection, request) {
        return {event: request.body.event, sender: request.headers["x-sender"]};
    }
}

Dynamic webhook triggers

A DYNAMIC_WEBHOOK trigger registers its URL with the provider. Add webhookEnable and webhookDisable alongside webhookRequest:

{
    name: "onIssue",
    title: "On Issue",
    type: "DYNAMIC_WEBHOOK",
    webhookEnable: function (input, connection, args) {
        // args.webhookUrl is the URL the platform minted for this workflow.
        return {subscriptionId: "sub-123"};
    },
    webhookDisable: function (input, connection, args) {
        // args holds what webhookEnable returned, for example args.subscriptionId.
    },
    webhookRequest: function (input, connection, request) {
        return request.body;
    }
}

webhookEnable runs when a workflow using the trigger is enabled. Whatever object it returns is stored and passed to webhookDisable when the workflow is disabled. A DYNAMIC_WEBHOOK trigger without one of the three functions fails when that function would run.

Connections

The optional connection member declares the component's connection type. The Connections page can then create connections of that type, the workflow editor offers them on the component's steps, and perform receives the selected connection's parameters as its connection argument.

Member
baseUriA string, the API's base URL.
authorizationsA list of authorizations. A connection without it, but with properties, gets one implicit CUSTOM authorization.
propertiesConnection-level properties. They apply to every authorization that declares no properties of its own.

An authorization has a type and optional properties, authorizationUrl, tokenUrl, refreshUrl, scopes (a list of strings) and apply. type is one of API_KEY, BASIC_AUTH, BEARER_TOKEN, CUSTOM, DIGEST_AUTH, OAUTH2_AUTHORIZATION_CODE, OAUTH2_AUTHORIZATION_CODE_PKCE, OAUTH2_CLIENT_CREDENTIALS, OAUTH2_IMPLICIT_CODE or OAUTH2_RESOURCE_OWNER_PASSWORD. For OAuth2 types the platform runs the whole flow: the authorization redirect, the callback, the token exchange and the refresh. The component only declares the endpoints.

connection: {
    baseUri: "https://api.example.com",
    authorizations: [
        {
            type: "OAUTH2_AUTHORIZATION_CODE",
            authorizationUrl: "https://example.com/oauth/authorize",
            tokenUrl: "https://example.com/oauth/token",
            scopes: ["read", "write"],
            properties: [
                {name: "clientId", type: "STRING", label: "Client Id", required: true},
                {name: "clientSecret", type: "STRING", label: "Client Secret", required: true}
            ]
        }
    ]
}

authorizationUrl, tokenUrl and refreshUrl take a string or a function of the connection parameters, for region- or tenant-specific endpoints. The function must return a string:

tokenUrl: function (connection) {
    return "https://" + connection.region + ".example.com/oauth/token";
}

An authorization's apply(connection) function overrides how the credentials decorate outgoing requests. It returns {headers, queryParameters}, each an object whose values are strings or lists of strings:

{
    type: "CUSTOM",
    properties: [{name: "token", type: "STRING", label: "Token", required: true}],
    apply: function (connection) {
        return {headers: {"X-Api-Token": connection.token}};
    }
}

apply runs on every request the connection makes, so each request pays for one more evaluation of the file.

A complete JavaScript component

A component with an API key connection, an action with dynamic options and a polling trigger:

({
    name: "acmeTasks",
    title: "Acme Tasks",
    description: "Create and watch tasks in Acme.",
    version: 1,
    connection: {
        baseUri: "https://api.acme.example",
        authorizations: [
            {
                type: "BEARER_TOKEN",
                properties: [{name: "token", type: "STRING", label: "API Token", required: true}]
            }
        ]
    },
    actions: [
        {
            name: "createTask",
            title: "Create Task",
            description: "Creates a task in a project.",
            tool: true,
            properties: [
                {
                    name: "projectId",
                    type: "STRING",
                    label: "Project",
                    required: true,
                    options: function (input, connection, searchText) {
                        return [
                            {label: "Website", value: "p-1"},
                            {label: "Mobile App", value: "p-2"}
                        ];
                    }
                },
                {name: "title", type: "STRING", label: "Title", required: true},
                {name: "notes", type: "STRING", label: "Notes", controlType: "TEXT_AREA"}
            ],
            output: {
                type: "OBJECT",
                properties: [
                    {name: "id", type: "STRING"},
                    {name: "title", type: "STRING"}
                ]
            },
            perform: function (input, connection, context) {
                const response = context.http({
                    method: "POST",
                    url: "https://api.acme.example/projects/" + input.projectId + "/tasks",
                    body: {content: {title: input.title, notes: input.notes}, contentType: "JSON"},
                    configuration: {responseType: "JSON"}
                });

                context.log("INFO", "Created task " + response.body.id);

                return response.body;
            }
        }
    ],
    triggers: [
        {
            name: "newTask",
            title: "New Task",
            type: "POLLING",
            properties: [{name: "projectId", type: "STRING", label: "Project ID", required: true}],
            output: {type: "OBJECT", properties: [{name: "id", type: "STRING"}]},
            poll: function (input, connection, closureParameters) {
                const lastSeen = closureParameters.lastSeen || 0;

                return {records: [], closureParameters: {lastSeen: lastSeen}};
            }
        }
    ]
})

A Python component

The same contract in Python. Define the functions with def, then end the file with the types.SimpleNamespace:

import types


def list_projects(input, connection, search_text):
    return [
        {"label": "Website", "value": "p-1"},
        {"label": "Mobile App", "value": "p-2"},
    ]


def create_task(input, connection, context):
    response = context.http({
        "method": "POST",
        "url": "https://api.acme.example/projects/" + input["projectId"] + "/tasks",
        "body": {"content": {"title": input["title"]}, "contentType": "JSON"},
        "configuration": {"responseType": "JSON"},
    })

    context.log("INFO", "Created a task")

    return response["body"]


types.SimpleNamespace(
    name="acmeTasksPython",
    title="Acme Tasks (Python)",
    version=1,
    connection={
        "baseUri": "https://api.acme.example",
        "authorizations": [
            {
                "type": "BEARER_TOKEN",
                "properties": [{"name": "token", "type": "STRING", "label": "API Token", "required": True}],
            }
        ],
    },
    actions=[
        {
            "name": "createTask",
            "title": "Create Task",
            "properties": [
                {"name": "projectId", "type": "STRING", "label": "Project", "required": True,
                 "options": list_projects},
                {"name": "title", "type": "STRING", "label": "Title", "required": True},
            ],
            "perform": create_task,
        }
    ],
)

The Java contract

A Java custom component is a jar that contains a ComponentHandler implementation, exactly like a built-in component. The Developer Guide and the component specification cover the full Java DSL: components, actions, triggers, connections and properties.

What the loader requires of the jar:

  • A ComponentHandler registered for ServiceLoader. Annotate the handler with @AutoService(ComponentHandler.class) (or write META-INF/services/com.bytechef.component.ComponentHandler by hand). The loader uses the first handler it finds, so put one component in each jar.
  • An icon, optionally. An inline SVG passed to .icon(...) is used as is. For .icon("path:<path>") the loader reads that file from the jar. Without an inline icon, or when the path: file is missing, it tries assets/<name>.svg and then assets/sample.svg. A jar with no icon at all still loads; the component just has no icon.
  • Everything except the ByteChef API and the JDK inside the jar. Classes in com.bytechef.* and in the JDK's own packages come from the server. The JDK's packages are those of its runtime modules: java.*, most of jdk.*, and JDK packages outside them, such as javax.net.ssl, javax.crypto, javax.xml, org.w3c.dom and sun.misc. The JDK's tool modules are not among them, so the server does not provide the compiler, attach or debugger APIs (com.sun.tools.javac, com.sun.tools.attach, com.sun.jdi). Every other class is loaded only from your jar, with no fallback to the server's class path. Build against the ByteChef component-api and definition-api without bundling them, and bundle every other runtime dependency (a fat or shaded jar). Do not put your own classes in a com.bytechef package or in a JDK package. A jar's copy of a JDK package, such as an xml-apis jar's org.w3c.dom, is ignored in favor of the JDK's. javax.* packages the JDK does not have, such as javax.annotation from jsr305, still load from your jar. Resources follow the same rule as classes.

The component's name and version come from the ComponentDefinition (component("name").version(2); the version defaults to 1).

Java components cannot be edited in ByteChef. To change one, rebuild the jar and upload it again; see Versions and drafts for what an upload does to an existing version.


Example: the Java sample

bytechef-sample-custom-component-java is a Gradle project with one component, sampleCustomComponentJava, that has one action, sampleAction. The ByteChef API jars it compiles against are checked in under libs/. The listings below omit the files' license headers.

build.gradle.kts:

plugins {
    id("java")
}

group = "org.sample"
version = "1.0.0"

repositories {
    mavenCentral()

    flatDir {
        dirs("lib")
    }
}

dependencies {
    annotationProcessor("com.google.auto.service:auto-service:1.1.1")

    implementation("com.google.auto.service:auto-service:1.1.1")
    implementation(files("libs/component-api-1.0.jar"))
    implementation(files("libs/definition-api-1.0.jar"))

    testImplementation(platform("org.junit:junit-bom:5.10.0"))
    testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks.test {
    useJUnitPlatform()
}

tasks.jar {
    archiveBaseName.set("sample-custom-component-java")
}

src/main/java/org/sample/customcomponent/SampleComponentHandler.java registers the handler and assembles the component:

package org.sample.customcomponent;

import com.bytechef.component.ComponentHandler;
import com.bytechef.component.definition.ComponentCategory;
import com.bytechef.component.definition.ComponentDefinition;
import com.google.auto.service.AutoService;
import org.sample.customcomponent.connection.SampleConnection;
import org.sample.customcomponent.action.SampleAction;

import static com.bytechef.component.definition.ComponentDsl.component;
import static org.sample.customcomponent.constant.SampleConstants.SAMPLE_CUSTOM_COMPONENT;

/**
 * @author Ivica Cardic
 */
@AutoService(ComponentHandler.class)
public class SampleComponentHandler implements ComponentHandler {

    private static final ComponentDefinition COMPONENT_DEFINITION = component(SAMPLE_CUSTOM_COMPONENT)
        .title("Sample Custom Component")
        .description("Sample custom component description.")
        .icon("path:assets/sample.svg")
        .categories(ComponentCategory.HELPERS)
        .connection(SampleConnection.CONNECTION_DEFINITION)
        .actions(SampleAction.ACTION_DEFINITION);

    @Override
    public ComponentDefinition getDefinition() {
        return COMPONENT_DEFINITION;
    }
}

src/main/java/org/sample/customcomponent/action/SampleAction.java declares one string property and an object output with key and message, and returns a record built from it:

package org.sample.customcomponent.action;

import com.bytechef.component.definition.ActionContext;
import com.bytechef.component.definition.ComponentDsl.ModifiableActionDefinition;
import com.bytechef.component.definition.Parameters;

import static com.bytechef.component.definition.ComponentDsl.action;
import static com.bytechef.component.definition.ComponentDsl.object;
import static com.bytechef.component.definition.ComponentDsl.outputSchema;
import static com.bytechef.component.definition.ComponentDsl.string;
import static org.sample.customcomponent.constant.SampleConstants.SAMPLE_ACTION;

/**
 * @author Mario Cvjetojevic
 */
public final class SampleAction {

    public static final ModifiableActionDefinition ACTION_DEFINITION = action(SAMPLE_ACTION)
        .title("Sample Action")
        .description("Sample action description")
        .properties(
            string("property1")
                .label("Property1")
        )
        .output(
            outputSchema(
                object()
                    .properties(
                        string("key"),
                        string("message"))))
        .perform(SampleAction::perform);

    private SampleAction() {
    }

    public static Record perform(
        Parameters inputParameters, Parameters connectionParameters, ActionContext actionContext) {

        return new Result("key1", "Hello " + inputParameters.get("property1"));
    }

    record Result(String key, String message) {
    }
}

src/main/java/org/sample/customcomponent/connection/SampleConnection.java is a bearer token connection against the placeholder base URI https://api.example.com, so using the component in a workflow needs a connection with any token value. Point the base URI at your API and swap the authorization for the one it needs:

package org.sample.customcomponent.connection;

import com.bytechef.component.definition.Authorization;
import com.bytechef.component.definition.Authorization.AuthorizationType;
import com.bytechef.component.definition.ComponentDsl.ModifiableConnectionDefinition;

import static com.bytechef.component.definition.ComponentDsl.authorization;
import static com.bytechef.component.definition.ComponentDsl.connection;
import static com.bytechef.component.definition.ComponentDsl.string;

public class SampleConnection {

    public static final ModifiableConnectionDefinition CONNECTION_DEFINITION = connection()
        .baseUri((connectionParameters, context) -> "https://api.example.com")
        .authorizations(
            authorization(AuthorizationType.BEARER_TOKEN)
                .title("Bearer Token")
                .properties(
                    string(Authorization.TOKEN)
                        .label("Token")
                        .required(true)));

    private SampleConnection() {
    }
}

src/main/java/org/sample/customcomponent/constant/SampleConstants.java holds the names:

package org.sample.customcomponent.constant;

/**
 * @author Ivica Cardic
 */
public final class SampleConstants {

    public static final String SAMPLE_ACTION = "sampleAction";
    public static final String SAMPLE_CUSTOM_COMPONENT = "sampleCustomComponentJava";

    private SampleConstants() {
    }
}

The icon lives at src/main/resources/assets/sample.svg, the path the handler declares with .icon("path:assets/sample.svg").

Build

The Gradle wrapper (Gradle 9.4.1) needs JDK 25:

git clone https://github.com/bytechefhq/bytechef-sample-custom-component-java.git
cd bytechef-sample-custom-component-java
./gradlew jar

The jar is written to build/libs/sample-custom-component-java-1.0.0.jar. Check that it contains META-INF/services/com.bytechef.component.ComponentHandler and assets/sample.svg:

unzip -l build/libs/sample-custom-component-java-1.0.0.jar

Deploy

Upload the jar from Settings → Custom Components → New Component → Import Component, or through the API:

curl -X POST "$BYTECHEF_URL/api/platform/v1/custom-components/deploy" \
  -H "Authorization: Bearer $BYTECHEF_ADMIN_API_KEY" \
  -F "componentFile=@build/libs/sample-custom-component-java-1.0.0.jar"

The component appears as Sample Custom Component, version 1, published and enabled. Add its Sample Action to a workflow, fill in Property1 and run the step: the output is {"key": "key1", "message": "Hello <value>"}.


Example: the JavaScript sample

bytechef-sample-custom-component-javascript contains one file that matters, src/sample_custom_component.js, and that file is what you upload. There is no build step:

({
  name: 'sampleCustomComponentJavaScript',
  title: 'Sample Custom Component',
  description: 'A sample custom component written in JavaScript.',
  version: 1,
  actions: [
    {
      name: 'sampleAction1',
      title: 'Sample Action 1',
      description: 'Builds a greeting for a name.',
      properties: [
        {
          name: 'name',
          type: 'STRING',
          label: 'Name',
          required: true,
        },
      ],
      output: {
        type: 'OBJECT',
        properties: [
          { name: 'message', type: 'STRING' },
        ],
      },
      sampleOutput: { message: 'Hello, ByteChef' },
      perform(input, connection, context) {
        context.log('INFO', `Greeting ${input.name}`);

        return { message: `Hello, ${input.name}` };
      },
    },
  ],
});

The file is one parenthesized object expression, so the value it evaluates to is the definition. Do not use export, module.exports, require or a bundler: they hide the definition from the server. The action has one required STRING property, name, and an OBJECT output that declares message, so downstream steps get a data pill for it. perform(input, connection, context) logs Greeting <name> with context.log('INFO', ...), which writes to the step's execution log (console.log goes to the server log instead), and returns {"message": "Hello, <name>"}. The component declares no connection; see Connections to add one.

Check

git clone https://github.com/bytechefhq/bytechef-sample-custom-component-javascript.git
cd bytechef-sample-custom-component-javascript
npm install
npm run check

npm run check evaluates src/sample_custom_component.js the way the server does and checks that it declares a name, a version and a perform function for each action. It prints:

sampleCustomComponentJavaScript v1: sampleAction1

npm run lint runs ESLint over the project.

Deploy

From the UI, Settings → Custom Components → New Component → Import Component, then pick src/sample_custom_component.js. Through the API:

curl -X POST "$BYTECHEF_URL/api/platform/v1/custom-components/deploy" \
  -H "Authorization: Bearer $BYTECHEF_ADMIN_API_KEY" \
  -F "componentFile=@src/sample_custom_component.js"

The file must keep its .js extension: ByteChef picks the language from it. The component appears as Sample Custom Component, version 1, published. Add Sample Action 1 to a workflow, fill in Name and run the step. Because it is a script component, clicking its row opens the source editor, so you can continue in ByteChef: raise version to 2, save, and a draft of version 2 is created next to the published version 1.


Working in the UI

The Custom Components page

Settings → Custom Components lists every version of every custom component, sorted by name. Each row shows the title and the name, a version badge (v1), a language badge (JAVASCRIPT, PYTHON, JAVA), a Draft or Published badge, an enable/disable switch, the last modified time, and a ⋮ menu with Delete.

  • The chevron at the start of every row expands it to show the component's actions and triggers, read-only, on an Actions and a Triggers tab. The definition is loaded from the stored component when you expand the row; if a JavaScript or Python draft's source cannot be loaded, the row says so instead.
  • Clicking the title of a JavaScript or Python row opens its source editor. Hovering such a row underlines the title.
  • A Java row has no editor: clicking its title does nothing.

Delete asks for confirmation, then removes that version and its stored file. It does not check whether workflows still use the version.

The New Component menu

New Component in the page header (or in the empty state, when there are no custom components yet) opens a menu with two entries:

Creating a component

The New Custom Component dialog ("Create an empty custom component and start building it.") has two fields:

Field
NameRequired, up to 128 characters: a letter followed by letters and digits, for example acmeTasks. It becomes the component's name and title. It must not be taken by another custom component (in any version) or by a built-in component. The name is part of every step type that uses the component.
LanguageJavaScript, the only language that can be created in ByteChef. To start in Python, write the file and import it.

Create generates a starter component, version 1, as a draft, and opens it in the source editor. The starter declares one action, myAction, with one input property, a perform(input, connection, context) that returns its input, and commented-out examples of a connection, context.log and context.http.

The source editor

The editor page shows a back arrow, the component's title, its language badge and its Draft or Published badge, with Save and Publish buttons, above a Monaco editor with the source.

  • Save is enabled once you change the source. The server loads the edited source before it stores it, so source that does not evaluate, or that breaks the contract, is rejected with the loader's error and nothing is saved.
  • Publish is enabled on a draft with no unsaved changes. It makes the draft visible to workflows.

What Save does depends on the version you are editing:

  • A draft: the draft is updated in place. You may change its version, as long as no other version of the component has that number.
  • A published version: you must raise version above the highest existing version of the component. Save then creates a new draft with that version and the editor switches to it. The published version is unchanged and keeps serving workflows.

The source cannot change the component's name.

Autocomplete

Inside an action's perform, the source editor suggests http and log after context., the action's declared property names after input., and the names in connection.properties after connection.. It reads them from the source as you type, so a property you add shows up without saving. See Code Editor Autocomplete for examples and limits, and the JavaScript sample for the source shape it reads.

Importing files

The Import Custom Component dialog ("Upload a custom component file to deploy it to the platform.") takes one or more files: click the drop zone to browse. It accepts .jar, .js and .py files, or only .js and .py when Java uploads are off. Import uploads the files one by one and shows the result of each.

An import publishes immediately; see Versions and drafts.

Versions and drafts

To release a new version of a published script component:

  1. Open the published version and raise version in the source above the highest existing version, for example from version: 1 to version: 2.
  2. Save. A draft of version 2 is created and opened.
  3. Keep editing and saving the draft.
  4. Publish when it is ready. Version 1 stays published next to version 2, and each workflow keeps the version it was built with until you change its steps.

An upload, through the import dialog or the API, works by name and version instead:

The uploaded file declaresResult
A name and version that do not exist yetA new version, already published and enabled.
The name and version of a published versionThat version's file, title, description and icon are replaced in place. Workflows using it pick up the change. The file must be in the same language as the version it replaces; a different language is rejected with LANGUAGE_MISMATCH.
The name and version of a draftRejected with VERSION_ALREADY_EXISTS. Publish or delete the draft first.

Errors

ErrorCause
VERSION_NOT_BUMPEDSaving a published version without raising version above the highest existing version.
DRAFT_ALREADY_EXISTSSaving a published version while the component already has a draft. Edit, publish or delete that draft.
VERSION_ALREADY_EXISTSA draft's new version collides with another version, or an upload targets a version owned by a draft.
COMPONENT_NOT_DRAFTPublishing something that is not a draft.
COMPONENT_ALREADY_EXISTSCreating a component whose name any version, published or draft, already uses.
INVALID_COMPONENT_NAMEA component, action or trigger name that is not a letter followed by letters and digits (at most 128 characters), or a component name a built-in component already uses.
LANGUAGE_MISMATCHAn upload replaces a published version with a file in a different language.
SOURCE_RENAME_UNSUPPORTEDThe edited source declares a different name.
JAVA_SOURCE_NOT_EDITABLEReading or saving the source of a Java component.
LANGUAGE_NOT_SUPPORTEDCreating a component in a language other than JavaScript, or uploading a Ruby file.
JAVA_CUSTOM_COMPONENT_UPLOAD_DISABLEDUploading a .jar while Java uploads are off.

Deploying through the API

Deploy from CI or a script with the public endpoint:

POST /api/platform/v1/custom-components/deploy
Bodymultipart/form-data with one file part, componentFile.
LanguageTaken from the file name's extension: .jar, .js or .py.
AuthenticationAuthorization: Bearer <key> with an Admin API key. Workspace and embedded API keys are rejected.
AuthorizationThe key's owner must have the ADMIN authority.
Success204 No Content.

The upload follows the rules in Versions and drafts: a new name and version is created published, an existing published version is replaced in place, and a version owned by a draft is rejected. A rule violation, such as JAVA_CUSTOM_COMPONENT_UPLOAD_DISABLED or VERSION_ALREADY_EXISTS, answers 400 with a problem detail. A key whose owner is not an administrator answers 403.

curl -X POST "$BYTECHEF_URL/api/platform/v1/custom-components/deploy" \
  -H "Authorization: Bearer $BYTECHEF_ADMIN_API_KEY" \
  -F "componentFile=@acme_tasks.js"

BYTECHEF_URL is the server's base URL, for example http://localhost:9555 for a local development server. The deploy endpoint runs on the instance that hosts the coordinator.

The import dialog uses a second endpoint, POST /api/platform/internal/custom-components/deploy, with the same body and the same 204 response. It authenticates with the signed-in user's session cookie and CSRF token instead of an API key, and is meant for the ByteChef client, not for scripts.


Restricting Java uploads

A Java custom component is arbitrary bytecode running in the server JVM. To accept only sandboxed script components, turn Java uploads off:

PropertyEnvironment variableDefault
bytechef.component.custom-component.java.enabledBYTECHEF_COMPONENT_CUSTOM_COMPONENT_JAVA_ENABLEDtrue

With false:

  • Uploading a .jar, through the import dialog or the API, fails with JAVA_CUSTOM_COMPONENT_UPLOAD_DISABLED.
  • The import dialog accepts only .js and .py files.
  • JavaScript and Python components, and Java components uploaded before the switch, keep working.

Code workflows have their own switch, bytechef.workflow.code-workflow.java.enabled. See Environment Variables.


How custom components run

A published, enabled custom component is part of the component catalog: it appears in the workflow editor, its connection type appears on the Connections page, its tools appear among the AI agent's tools, and Component Visibility policies apply to it like to a built-in component. Drafts are not in the catalog, so a draft cannot be run from a workflow. Publish it, or test the logic in a Script step first.

  • JavaScript and Python components run in the strict GraalVM sandbox, the same one behind the Script component: no host class access, no file system, process or thread creation, no environment access, and only the network access context.http provides. Each call gets a fresh guest context that evaluates the file again, and the sandbox's CPU, memory and time limits apply to each call. See Script Sandbox for the limits and how to tune them, and Task Runners for running guest code outside the server process.
  • Java components are loaded in the server JVM through an isolating class loader per component version, so two components cannot see each other's classes. The loaded handler is cached and reused across calls. A new upload is picked up without a restart.

If a component fails to load, for example because its source no longer evaluates, it is left out of the catalog and the server logs a warning naming it. The other components keep working.

Audit

Every upload, through the import dialog or the API, is recorded in the audit log as CUSTOM_COMPONENT_SAVED, with the component's id, name, version and language. Creating a component from the starter template records CUSTOM_COMPONENT_CREATED with the same fields, publishing a draft records CUSTOM_COMPONENT_PUBLISHED, enabling or disabling records CUSTOM_COMPONENT_ENABLED_UPDATED, and deleting records CUSTOM_COMPONENT_DELETED. Edits to a draft's source are not recorded one by one; publishing the draft records the result.

Scaffolding a Java component with the CLI

The ByteChef CLI generates a Java component project from an OpenAPI specification:

bytechef component init --name my-component --open-api-path ./openapi.yaml --output-path .
Option
--name, -nRequired. The component name; it is lower-cased.
--output-path, -oRequired. Where to write the generated project.
--open-api-pathA local file or an http(s) URL. The command generates nothing without it.
--base-package-nameThe package of the generated classes. Defaults to com.bytechef.component. Change it for a custom component, since classes in com.bytechef packages are not loaded from a custom component jar.
--version, -vThe component version. Defaults to 1.
--internal-componenttrue for a component that ships with the platform. Defaults to false.

The generated code is yours to edit. Build it into a jar that meets the Java contract and upload it. For a REST API that needs no code at all, an API connector turns the specification into a component directly.

See also

How is this guide?

Last updated on

On this page