> ## Documentation Index
> Fetch the complete documentation index at: https://botpress-pb-update-api.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Actions

<Icon icon="bolt" /> Actions are **custom AI-generated tools** you can provide to your bot.

<Tabs>
  <Tab title="Just write your prompt...">
    <Frame>
      <img alt="Action prompt" className="block dark:hidden" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/action-prompt.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=66c1783386d60b2c5af6da6359f9da4c" width="1244" height="444" data-path="studio/concepts/assets/action-prompt.png" />

      <img alt="Action prompt" className="hidden dark:block" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/action-prompt-dark.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=318a05bc13fe45de6952eeda383328e2" width="1244" height="444" data-path="studio/concepts/assets/action-prompt-dark.png" />
    </Frame>
  </Tab>

  <Tab title="then use the generated Action.">
    <Frame>
      <img alt="Generated action" className="block dark:hidden" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/generated-action.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=c5e30e2b70fbd8be854246234a8d8d2a" width="1840" height="714" data-path="studio/concepts/assets/generated-action.png" />

      <img alt="Actions" className="hidden dark:block" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/generated-action-dark.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=f73c7a8d54687e3e8a2d5f1fc0f82ae5" width="1840" height="714" data-path="studio/concepts/assets/generated-action-dark.png" />
    </Frame>
  </Tab>
</Tabs>

You can use Actions to extend your bot's general functionality beyond what's available with the default [Cards](/studio/concepts/cards/introduction) or [integrations](/integrations/get-started/introduction). For example:

* Make repeated API calls to an external service
* Perform a specific calculation multiple times
* Manipulate data and [variables](/studio/concepts/variables/overview)

<Tip>
  Actions are code-based, but you don't need to write the code yourself—AI does all the work based on your prompt.
</Tip>

***

## Overview

Actions are [TypeScript functions](https://www.typescriptlang.org/docs/handbook/2/functions.html) that execute their code whenever an [Autonomous Node](/studio/concepts/nodes/autonomous-node) calls them.

Just like [Execute Code Cards](/studio/concepts/cards/execute-code), Actions let your bot use custom code. However, they're different in two important ways:

* Actions are *only available in Autonomous Nodes*—they execute when AI decides they should
* Actions are *re-usable*—your Autonomous Node can call them as many times as it needs

***

## Create an Action

To create a new Action:

1. Go to the **<Icon icon="bolt" /> Actions** menu in the Studio.
2. Select **Create Action**.

This opens the editor for your new Action. From here, you have two options:

### Generate using AI (recommended)

You can generate the entire Action using AI. In the bottom-left corner, write a prompt that describes what you want your Action to do:

<Frame>
  <img alt="Action prompt example" className="block dark:hidden" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/action-prompt-example.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=d5b31d9dbac16782c637ff7c352bc05a" width="1240" height="450" data-path="studio/concepts/assets/action-prompt-example.png" />

  <img alt="Action prompt example" className="hidden dark:block" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/action-prompt-example-dark.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=d40cffacfa8b92ba681a473ca73f82d7" width="1240" height="450" data-path="studio/concepts/assets/action-prompt-example-dark.png" />
</Frame>

Your bot will generate code based on your prompt:

<Frame>
  <img alt="Generated Action code" className="block dark:hidden" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/generated-action-code.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=5da6650cb23fcfc06d79fa83b5929ff0" width="1772" height="686" data-path="studio/concepts/assets/generated-action-code.png" />

  <img alt="Generated Action code" className="hidden dark:block" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/generated-action-code-dark.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=630aa868a3784a793ca53922d142b132" width="1772" height="686" data-path="studio/concepts/assets/generated-action-code-dark.png" />
</Frame>

If you want to refine the code, you can keep prompting to make updates.

When you're happy with the generated code, select **Accept** to add it to your Action.

### Write code yourself

If you prefer, you can write the Action's code yourself—just edit the function on the right side of the editor.

<Note>
  For more information, check out our guide on [using code in Botpress Studio](/studio/guides/advanced/use-code).
</Note>

### Edit your Action's name/description

Whether you generate your Action with AI or write it by hand, you can edit its name and description. Just select them in the upper-left corner of the editor, then enter a new name/description.

***

## Use Actions

When you're ready to use an Action, you can add it to any Autonomous Node:

1. Select **+ Add Card** on any Node to open the Card tray.
2. Search for your Action, or find it under **Bot Actions**.
3. Add it to the Autonomous Node.

This gives your Autonomous Node access to execute the Action whenever it decides it's appropriate.

### Give your Autonomous Node instructions

If you add an Action to your Autonomous Node, you should add instructions to the Node's prompt so it knows when to use the Action. For example:

```wrap theme={null}
Use the `fetchApiData` Action when you need data from an external API.
```

For more information, check out our guide on prompting your [Autonomous Node](/studio/concepts/nodes/autonomous-node#prompting-tips).

### Manually provide inputs

By default, the Autonomous Node decides how to fill in the Action's input fields based on the conversation's context. However, you can manually fill in these fields if you'd prefer:

1. Select your Action from the Autonomous Node to open its inspector.
2. Select the input field you want to manually fill in, then select **<Icon icon="hand" /> Manual.**

Now, you can manually fill in the field. For example, with data stored in a variable:

<Frame>
  <img alt="Manually provide inputs" className="block dark:hidden" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/manual-inputs.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=39d0185029df3b0f151308487be34c5d" width="1264" height="618" data-path="studio/concepts/assets/manual-inputs.png" />

  <img alt="Manually provide inputs" className="hidden dark:block" src="https://mintcdn.com/botpress-pb-update-api/oD2ntPQ5dxiZJE1J/studio/concepts/assets/manual-inputs-dark.png?fit=max&auto=format&n=oD2ntPQ5dxiZJE1J&q=85&s=6087fc9021255f8930d86059cce5223e" width="1264" height="618" data-path="studio/concepts/assets/manual-inputs-dark.png" />
</Frame>

***

## Schemas

Actions use input and output [Schemas](/studio/concepts/schemas) to tell your bot what data they expect and what data to return.

Schemas are automatically created when you create an Action, and they automatically update when you edit your Action using AI. This means you don't have to worry about them if you're only using AI to generate your Action.

### Use custom Schemas

If you're writing any of your Action's code by hand, you can write or select a custom Schema:

1. In your Action's editor, select **<Icon icon="braces" /> Input Schema** or **<Icon icon="braces" /> Output Schema**.
2. Here, you can edit your Action's default Schema directly, or select a previously-created Schema from the drop-down menu.
