Lecca.io LogoLecca.io
Actions

Create Action

We are working on a CLI to make this easier

Create actions folder

Locate the your app folder in the apps directory and add a new actions folder if it doesn't exist already.

new-action.action.ts
your-new-app.app.ts

Create action file

Create a new file within your app's action folder. Make sure it ends with .action.ts.

Add your own values. We provided mock data to help initialize the process.

import { createAction, createTextInputField } from "@lecca-io/toolkit";
import { z } from "zod";
 
export const newAction = createAction({
  id: "your-new-app_action_new-action",
  name: "",
  description: "",
  aiSchema: z.object({}),
  inputConfig: [],
  run: async ({ configValue, connection }) => {},
  mockRun: async () => {},
});
  1. export const newAction = createAction

    • Replace newAction with the name of your action.
  2. Add an id: your-new-app_action_new-action

    • Make sure the id follows the format <app-id>_action_<action-name-in-kebab-case>
  3. Add a name for your action

  4. Add a brief one sentence description

  5. Add an AI Schema

    This is a zod schema used for AI to "fill out" the form to configure this action.

    Read more about the AI Schema.

  6. Add an Input Config

    This is used to generate the form for the UI to configure this action.

    Read more about the Input Config

  7. Define the run function.

    This is the function that runs during workflow steps or when an AI agent uses this action as a tool. Whatever is returned from this function can be used in subsequent steps in the workflow or by an AI agent.

    The common arguments used by this function are configValue and connection.

    1. configValue represents the Input Config or AI Schema that was used when the user or AI agent configuring this action.

    2. connection is the decrypted connection properties of the connection selected by the user when configuring this action. May contain an api key, accessToken, username & pass, or key pairs.

      If using an oauth2 connection, do not worry about handling refresh tokens, that is handled by the engine. Just make the api call assuming the access token is valid.

  8. Define the mock function.

    The mock function is used by users when they want to generate a mock output instead of making an real api call to their third party integration.

    Ouput data is used to map to other nodes in the workflow builder. This is done by clicking Save & Test in the configuration form.

Add new action to the app's actions property

your-new-app.app.ts
import { createApp } from "@lecca-io/toolkit";
 
export const yourNewApp = createApp({
  ...
  actions: [newAction], 
  triggers: [],
  connections: [],
});

On this page