Understanding functional nodes
In the graph we have simple nodes, containing the messages fired by the chatbot and functional nodes. As per name, functional nodes contain functions, that is to say nodes containing some logic. With functions you can set built-in logic rules or execute API calls to your core systems and associate a chatbot behaviour according to every function’s output.
All functional nodes share the same principle: the flow of the conversation varies according to the previous user input. In other words, the functional node contains some logic to select the conversational path depending on the history of every user’s chat.
In order to create a functional node select the 🔹 icon from the controls toolbar at the left of the board and exactly as per simple nodes, click in any empty space in the board.
Every function has outputs represented through red edges. In a functional node, edges are predefined, therefore, when creating new ones the edge control panel will display a dropdown with the available options. For example, in the function below, we check an email address and are given valid and invalid outputs as options.
There are Standard Functions, which are provided directly by Spixii and Custom Functions, with possibility to enter custom logic. We can see some examples starting from Standard Functions.
Most of the Standard Functions are validation functions. As an example, the simplest scenario is a function with two outputs: valid and not valid. When the input from the user is not valid, you can create an outcoming edge pointing to an error message. When the input is valid, the conversation can continue as per the “golden path” to the following conversational node.
Some of the Standard Function examples include:
is_date_in_range, checks whether the date selected by the user is inside or outside a desired range. As function outputs you have 3 scenarios: a date before the allowed range, a date after the allowed range and the one within the allowed range. For each scenario, you can have a specific chatbot message or conversation flow.
is_email, checks if the email entered by the user is aligned with ISO standard email address format. As outputs we have valid and not valid. As outputs we have valid and not valid.
is_equal, verify if two variables are equal. As outputs we have valid and not valid.
is_null, checks if a variable is empty (not defined, defined as null or defined as an empty string). As outputs we have valid and not valid.
With Custom Functions you can define a new function along with its outputs. Spixii CPA provides a powerful Function Manager to create and manage the function straight from the platform.
When creating a new functional node, the option
Create new function is available from the sidebar. When clicking the button, the function control panel will allow you to specify name and description for the new function.
The Function Manager contains the following elements:
The Source code panel, that allows you to enter or even import your code. Through the Python coding language, specific logic can be defined for the conversation flow.
The Arguments panel,
The Returns panel, where the outputs of the function are defined. Outputs correspond with edges outcoming from the functional node.
The Function simulator panel, where the function can be tested while creating it with the help of the development logs to the right.