Function step
The Function step is a powerful feature that allows developers to create custom logic and operations within their AI Agents. This document will guide you through the process of creating, configuring, and using a Function step on the canvas.
For a large library of pre-made functions, check out the function marketplace.
Using a Function Step
Once you've either developed or imported your function, you can:
- Drag the Function step on canvas, which is nested under Dev section
- Click on the Function step to open the step editor
- You can either select an existing function from the dropdown or create a new one by clicking the "Create function" button.
Configuring the Function Step
Next we will be setting up the selected function to integrate with your project.
- Input Variable Mapping
- Map the input variables by assigning values or variables from your project to the function's parameters.
- Note: Copies of these variables are made when they're passed to the function, so any changes you might make inside the function won't be reflected on the variable passed in. To have a variable updated, put it in the output section.
- Example: { text } is assigned to receive a value or variable from your flow that contains the text you wish to process.
- Map the input variables by assigning values or variables from your project to the function's parameters.
![](https://files.readme.io/7f687c4-image.png)
- Output Variable Mapping
- Define which variable in your flow will receive the output of the function.
- Example: The output of the function, { output }, is applied to {target_variable}.
Using the Function Step
- Connecting to Other Blocks
- Once configured, your Function step can be connected to other blocks.
- Connect the "default" port of the Function step to the next step in your flow where you want to utilize the output from the Function step.
- Testing Your Function
- After setting up your function with input and output mappings, you can test its behavior using the Voiceflow prototype.
- Alternatively, you can select the "Run" button on the bottom of the function's step editor to execute the function.
Updated about 1 month ago