> For the complete documentation index, see [llms.txt](https://docs.flexy.bot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flexy.bot/modules/scripting/triggers/function.md).

# Function

**Introduction**

The "Function" trigger allows you to define a custom function within your automation. This trigger is useful for encapsulating reusable logic and enabling other parts of your automation to call and execute it.

**Configuration**

* **Inputs**: A list of input parameters that the function can accept. Each input includes:
  * **Name**: The name of the input, used to identify it.
  * **Schema**: The data type of the input, selected from a list of user-definable types. This parameter is required.
* **Return**: Specifies the value that the function will return after execution. This parameter is optional and can be defined based on your automation's needs.

**Outputs**

* **Inputs**: An object representing the function's inputs that are received when the function is called. This output is generated only if you define inputs in the configuration.

This trigger enables modular and reusable code within your automation workflows, making it easier to manage complex logic.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flexy.bot/modules/scripting/triggers/function.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
