Using Virtual Agent Designer (legacy): Function Component

The Function component allows conversational designers to access and manipulate data using JavaScript code (e.g., adapt data to a conversational format and specify variable conditions, among other functionalities). 

Adding a Function component 


1. Click a Virtual Agent model [1] in the list and select Designer [2].


  • Under “Automation”, select the Function component [3] and then drag it to a canvas on your right side [4].
  • Double-click the component. Then, the component settings panel [5] will appear.
  • Provide the required details of the component:
    • “Component name” [6]: The name of the Function component. The name can only contain letters, numbers (except as a first character), and underscores, and can be as long as 30 characters.
    • “Function” [7]: Here you can define the code editor field to execute JavaScript code. In this component, you can use standard JavaScript code, as well as the following two methods that allow the conversational designers to manage Virtual Agent’s variables, namely:
      • Context.getVariable(variable name): Get value from a variable. This method allows getting the Virtual Agent’s variable data so that you are able to use those values in the logic execution previously defined.
      • Context.setVariable(variable name, new value): Define the value of a custom variable. This method allows you to set the Virtual Agent’s variable data so that you are able to execute the logic that you previously defined, and store the transformed data into a VA’s variable. Note: The system’s variable values cannot be changed (e.g. the utterance, caller ID, and confidence score).
      • The code editor has 20 lines by default and will increase in height if you keep editing below, with the scroll on the side. 
      • There is a limit of 1000 characters and another for an execution timeout of 2 seconds, meaning that if you have code exceeding 2 seconds of running time, the code will stop running and the component will move with the error exit. 
  • Click Save [8].
  • After the component is created, you can connect it with another component: One for “Success” and another for an “Error” scenario. Keep in mind that if the component is not directly or indirectly connected to a Flow Trigger component, it will be ignored when the flow is executed.

Note: A red exclamation mark will appear on the component node if any required field is invalid. Hold the pointer over it to see further details.

Deleting a Function component 

1. On your canvas, click the Function component you want to delete, and then press the backspace key (Windows) or the delete key (Mac) on your keyboard. Alternatively, you can double-click the component and select Delete in the side panel that appears.


2. Click Delete component in the dialog that appears to confirm the deletion.

All Articles ""
Please sign in to submit a request.