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

# Execute Code

The Execute Code Card lets you **run custom [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) code within a Node**.

You can use the Execute Code Card to extend the functionality of your bot beyond Studio's built-in Cards. For example, you can:

* Perform complex calculations
* Manipulate data and variables (see [variables in code](https://botpress.com/docs/studio/concepts/variables/in-code.md))
* Call external APIs
* Add guardrails such as custom error handling, rate limits, permission checks, and fallbacks

> [!NOTE]
>
> Execute Code Cards allow you to generate one-time code snippets at specific points in your Workflow. For reusable code snippets, use [Actions](https://botpress.com/docs/studio/concepts/actions.md).

> [!WARNING]
>
> You can't import external libraries within an Execute Code Card. To make API requests, you can use [Axios](https://axios-http.com/docs/intro).

## Generate code using AI

The Execute Code card allows you to generate code using AI, so you don't have to write it all from scratch:

![Generate code using AI](https://mintcdn.com/botpress/Lpe_dNeJOVvCwnlo/studio/concepts/cards/assets/execute-code.png?fit=max\&auto=format\&n=Lpe_dNeJOVvCwnlo\&q=85\&s=c3dbe52b8116a162e790a8842e637a50)

At the top of the code editor, write a prompt and hit enter to generate code using AI. You can then edit this code manually or ask AI to make revisions to it.

> [!NOTE]
>
> Review AI-generated code before production. Store secrets in [configuration variables](https://botpress.com/docs/studio/concepts/variables/scopes/configuration.md) (use `env` in code), and handle slow or failed requests with `try`/`catch`, timeouts, or fallback flows.


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