> ## Documentation Index
> Fetch the complete documentation index at: https://docs.typebot.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Action

An action is what a block can do when it is executed with Typebot. A [block](https://docs.typebot.com/contribute/the-forge/block.md) can have multiple actions.

Here is the `sendMessage` action definition:

```ts theme={null}
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.meta({ layout: {
      label: "Chat ID",
      placeholder: "@username",
    } }),
    text: option.string.meta({ layout: {
      label: "Message text",
      input: "textarea",
    } }),
  }),
});
```

> [!NOTE]
>
> The action execution logic is defined separately in a `handlers.ts` file. See
> the [Run](https://docs.typebot.com/contribute/the-forge/run.md) documentation for more information.

![Action example](https://mintcdn.com/typebot/rHkgfCATWjP6ntzz/images/contribute/action-example.png?fit=max\&auto=format\&n=rHkgfCATWjP6ntzz\&q=85\&s=e28dc669d3d39b48947e799d7bf99749)

## 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](https://docs.typebot.com/contribute/the-forge/block.md#props)), this
needs to be provided here.

**options** `z.ZodObject\<any\>`

The action configuration options. See [Options](https://docs.typebot.com/contribute/the-forge/options.md) 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&#x20;
[Server function + stream](https://docs.typebot.com/contribute/the-forge/run.md#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&#x20;
[Display embed bubble](https://docs.typebot.com/contribute/the-forge/run.md#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](https://docs.typebot.com/contribute/the-forge/fetcher.md) 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.

> [!NOTE]
>
> The action execution logic is now defined separately in a `handlers.ts` file
> using `createActionHandler()` and `createFetcherHandler()`. Check out the&#x20;
> [Run](https://docs.typebot.com/contribute/the-forge/run.md) documentation for more information on how to implement
> handlers.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.