#Arguments and returns
Definition of returns
The box Returns allows the CPA user to define the outgoing edges coming out from the functional node.
Every return is defined by a unique id
automatically assigned by the system, a value
and a key
(both optional).
Returns defined in the table will be available as function outputs in the Build module. For example, given the following list of returns:
The function outputs (which means the edges outgoing from the functional node) list will be like it shown below:
⚠️Important note: Every function must have at least one return.
Definition of arguments
If a function is required in multiple steps of the conversational process, then it may be useful to adopt a parameterized approach. This can be easily done with the Arguments configuration table.
Every argument can be assigned with a unique name
and optional default value
and key
.
The function is_equal
, for example, has the following arguments:
FirstVariable
default value:
default key:
SecondVariable
default value:
default key:
case_sensitive
default value: Y
default key:
validate_key
default value: N
default key:
The CPA user is able to assign the parameters straight from the function configuration in the Build tab.
Arguments can be used into the source code with the function get()
.
try:
# Get FirstVariable and SecondVariable
var1, var2 = get("FirstVariable"), get("SecondVariable")
# Consider value or key depending on the validate_key parameter
if get("validate_key")["value"] == "N":
var1, var2 = str(var1["value"]), str(var2["value"])
else:
var1, var2 = str(var1["key"]), str(var2["key"])
# Set to lower if not case sensitive
if get("case_sensitive")["value"] == "N":
var1, var2 = var1.lower(), var2.lower()
# Check if FirstVariable and SecondVariable are the same
if var1 == var2:
exit(1) # FirstVariable and SecondVariable are the same
exit(2) # FirstVariable and SecondVariable are different
except Exception as e:
print("Got the following unexpected error in the execution: " + str(e))
exit(2) # FirstVariable and SecondVariable are different