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

# Use Foundry functions in workflows and agents

> Call published Foundry functions from Ravenna workflows and AI agents to run custom code actions, integrations, and data lookups in your automations.

Once you publish a Foundry function, it's available in two places: as a step in a workflow, and as a tool your AI agents can use. A single function you build once works in both.

***

## In workflows

Published functions show up in the workflow builder alongside built-in actions.

<Steps>
  <Step title="Open a workflow">
    Go to **Workflows** and open or create a workflow.
  </Step>

  <Step title="Add the function as a step">
    In the step picker, find your function under **Code Actions**.
  </Step>

  <Step title="Map the inputs">
    Each function has input fields. Connect them to data from the workflow trigger or earlier steps. For example, map a ticket's requester email to the function's "email" input.
  </Step>

  <Step title="Use the outputs">
    The function's output is available to every step after it.
  </Step>
</Steps>

### Example

A common pattern is enriching a ticket with information from another tool:

1. **Trigger:** A new ticket is created.
2. **Foundry function:** Look up the requester in your CRM by email and return their company and plan.
3. **Update ticket:** Set custom fields with the CRM data and route the ticket based on the plan.

***

## With AI agents

Agents in your workspace can use published functions automatically. When a user asks something a function can help with, the agent calls it.

You can also point agents at specific functions in your <Tooltip tip="Natural language instructions that define agent behavior." headline="Agent rules" cta="Learn about agent rules" href="/documentation/automate/agents/configure">agent rules</Tooltip>. Reference a function by name with `@Function Name`:

<Prompt description="When a user asks about a customer, use @Look up CRM contact to find their details by email. Share the company, role, and plan with the user.">
  When a user asks about a customer, use @Look up CRM contact to find their details by email. Share the company, role, and plan with the user.
</Prompt>

You don't need to write any agent-facing documentation. When you publish a function, Foundry generates an AI tool prompt that tells agents what it does and when to use it. You can regenerate that prompt at any time from the function's **Configure** tab.

<Callout icon="sparkles" color="#7C3AED">
  See how teams wire published functions into real workflows and agent rules in the [Foundry examples](/guides/how-to/foundry/examples) guide.
</Callout>

***

## Who sees a function

A function is visible to the same workspaces its integrations are.

| Integration type       | Where the function is available      |
| ---------------------- | ------------------------------------ |
| Custom API integration | The workspace it was created in      |
| OAuth provider         | Every workspace in your organization |

For functions that use more than one integration, the most restrictive scope wins.

***

## Managing published functions

* **Unpublish** removes the function from workflows and agents. Workflows already running finish, but new runs won't start.
* **Update and republish** pushes a new version. Workflows and agents pick it up automatically.
* **Regenerate the AI tool prompt** if you've changed what the function does and want agents to learn the new behavior.

<Callout icon="link" color="#6B7280">
  Learn more about [building workflows](/documentation/automate/workflows/overview) and [configuring AI agents](/documentation/automate/agents/configure).
</Callout>
