> ## 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.

# 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](/studio/concepts/variables/in-code))
* 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](/studio/concepts/actions).
</Note>

<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).
</Warning>

## 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:

<Frame>
  <img alt="Generate code using AI" className="block dark:hidden" src="https://mintcdn.com/botpress-pb-update-api/dB6fsns919bYYGbE/studio/concepts/cards/assets/execute-code.png?fit=max&auto=format&n=dB6fsns919bYYGbE&q=85&s=9417f90d5711d5a0f8bd0c9c08afd15d" width="1442" height="262" data-path="studio/concepts/cards/assets/execute-code.png" />

  <img alt="Generate code using AI" className="hidden dark:block" src="https://mintcdn.com/botpress-pb-update-api/dB6fsns919bYYGbE/studio/concepts/cards/assets/execute-code-dark.png?fit=max&auto=format&n=dB6fsns919bYYGbE&q=85&s=36e38c678ab97f38057d66a7d362c6c6" width="1442" height="262" data-path="studio/concepts/cards/assets/execute-code-dark.png" />
</Frame>

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](/studio/concepts/variables/scopes/configuration) (use `env` in code), and handle slow or failed requests with `try`/`catch`, timeouts, or fallback flows.
</Note>
