Triggo Documentation
SDK

Create a Connector

API reference for createConnector() — assembles auth, actions, and triggers into a frozen ConnectorDefinition.

Create a Connector

createConnector() is the top-level factory that assembles authentication, actions, and triggers into an immutable ConnectorDefinition.

Signature

import { createConnector } from "@triggo/connector-sdk";

function createConnector(config: ConnectorConfig): ConnectorDefinition;

ConnectorConfig

FieldTypeRequiredDescription
namestringYesUnique connector identifier. Must be kebab-case (e.g., my-service).
displayNamestringYesHuman-readable name shown in the UI.
descriptionstringYesBrief description of what the connector integrates with.
authAuthDefinitionYesAuthentication configuration. Use ConnectorAuth.OAuth2(), .SecretText(), .CustomAuth(), or .None().
actionsActionDefinition[]YesArray of actions created with createAction().
triggersTriggerDefinition[]YesArray of triggers created with createTrigger().

ConnectorDefinition (Return Type)

The returned object is deeply frozen and includes everything from the config plus computed fields:

FieldTypeDescription
namestringThe kebab-case connector name.
displayNamestringHuman-readable name.
descriptionstringConnector description.
authAuthDefinitionThe auth definition passed in.
actionsreadonly ActionDefinition[]Frozen array of actions.
triggersreadonly TriggerDefinition[]Frozen array of triggers.
actionsMapReadonlyMap<string, ActionDefinition>Actions indexed by name for O(1) lookup.
triggersMapReadonlyMap<string, TriggerDefinition>Triggers indexed by name for O(1) lookup.
schemaConnectorSchemaAuto-generated JSON Schema for auth, action inputs, and trigger inputs.

Validation Rules

createConnector() throws on invalid input:

  • Name format -- must match /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/ (non-empty kebab-case)
  • Actions array -- must be an array (not null, not undefined)
  • Triggers array -- must be an array (not null, not undefined)
  • Duplicate action names -- throws if two actions share the same name
  • Duplicate trigger names -- throws if two triggers share the same name

Example

import {
  createConnector,
  createAction,
  createTrigger,
  ConnectorAuth,
  Property,
  TRIGGER_TYPES,
} from "@triggo/connector-sdk";

const auth = ConnectorAuth.SecretText({
  displayName: "API Key",
  description: "Your service API key.",
});

const fetchItems = createAction({
  name: "fetch_items",
  displayName: "Fetch Items",
  description: "Retrieves a list of items from the service.",
  props: {
    limit: Property.Number({
      displayName: "Limit",
      description: "Maximum number of items to return.",
      required: false,
      defaultValue: 10,
    }),
  },
  async run(context) {
    const limit = (context.propsValue.limit as number) ?? 10;
    const secret = (context.auth as { secret: string }).secret;
    const response = await fetch("https://api.example.com/items?limit=" + limit, {
      headers: { Authorization: `Bearer ${secret}` },
    });
    return response.json();
  },
});

export const exampleConnector = createConnector({
  name: "example-service",
  displayName: "Example Service",
  description: "Integrates with Example Service API.",
  auth,
  actions: [fetchItems],
  triggers: [],
});

Auto-Generated Schema

The schema field on the returned definition contains JSON Schema representations of:

  • schema.auth -- auth fields schema
  • schema.actions -- each action's input schema, keyed by action name
  • schema.triggers -- each trigger's input schema, keyed by trigger name

These schemas are used by the AI system to understand connector capabilities during pipeline generation.

Immutability

The returned ConnectorDefinition and all nested objects are deeply frozen via Object.freeze(). This prevents accidental mutation at runtime and ensures connectors remain stable across concurrent pipeline executions.

On this page