Function

Tahsim Ahmed
Tahsim Ahmed
  • Updated

Overview

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.

Using a Function Step

  1. Drag the Function step on canvas, which is nested under Dev section
    Screen Shot 2023-12-15 at 11.35.48 PM.png
  2. Click on the Function step to open the step editor
    Screen Shot 2023-12-15 at 11.36.37 PM.png
  3. You can either select an existing function from the dropdown or create a new one by clicking the "Create function" button.
    Screen Shot 2023-12-15 at 11.37.15 PM.png

Configuring the Function Step

Next we will be setting up the selected function to integrate with your project. 

Screen Shot 2023-12-15 at 11.37.58 PM.png

  1. Input Variable Mapping:
    • Map the input variables by assigning values or variables from your project to the function's parameters.
    • Example: { text } is assigned to receive a value or variable from your flow that contains the text you wish to process.
      Screen Shot 2023-12-15 at 11.50.07 PM.png
  2. 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}.
      Screen Shot 2023-12-15 at 11.50.24 PM.png

Using the Function Step

  1. 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.
      Screen Shot 2023-12-15 at 11.53.52 PM.png
  2. Testing Your Function:
    • After setting up your function with input and output mappings, you can test its behaviour using the Voiceflow prototype.
      Screen Shot 2023-12-15 at 11.56.17 PM.png
    • Alternatively, you can select the "Run" button on the step editor to execute the function. 


Best Practices

  1. Managing Inputs and Outputs: Design your function to handle different types of outputs gracefully, whether they are successful results or error messages.
  2. Documentation: Access Builder Notes by hovering over the function variables to see a description of what purpose they serve.  This is especially helpful when collaborating with a team.
    Screen Shot 2024-01-15 at 2.39.43 PM.png

  3. Testing: Thoroughly test your functions in various scenarios to ensure they work correctly across different inputs and situations.

 

Was this article helpful?

4 out of 7 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.