Skip to main content
An action is what a block can do when it is executed with Typebot. A block can have multiple actions. Here is the sendMessage action definition:
import { createAction, option } from "@typebot.io/forge";
import { auth } from "../auth";

export const sendMessage = createAction({
  auth,
  name: "Send message",
  options: option.object({
    chatId: option.string.layout({
      label: "Chat ID",
      placeholder: "@username",
    }),
    text: option.string.layout({
      label: "Message text",
      input: "textarea",
    }),
  }),
});
The action execution logic is defined separately in a handlers.ts file. See the Run documentation for more information.
Action example

Props

name
string
required
The name of the action.
auth
Auth
If the block requires authentication, the auth object needs to be passed to the action.
baseOptions
z.ZodObject<any>
If the block has options defined (see block props), this needs to be provided here.
options
z.ZodObject<any>
The action configuration options. See Options for more information.
getStreamVariableId
(options) => string | undefined
If the action can stream content, this function should return the variable ID that will receive the streamed content. See Server function + stream for more information.
getEmbedSaveVariableId
(options) => string | undefined
If the action displays an embed bubble that waits for an event, this function should return the variable ID where the event data will be saved. See Display embed bubble for more information.
getSetVariableIds
(options) => string[]
A function that returns an array of variable IDs that will be set by this action. This is used for analytics and tracking purposes.
fetchers
{ id: string }[]
An array of fetcher references used to populate dropdown options dynamically. Each fetcher should be exported from the action file and implemented in the handlers file. See Fetcher for more information.
turnableInto
TurnableIntoParam[]
An array of block IDs that this action can be converted into. This allows users to easily switch between similar blocks while preserving their configuration.
The action execution logic is now defined separately in a handlers.ts file using createActionHandler() and createFetcherHandler(). Check out the Run documentation for more information on how to implement handlers.