Functions
In this section, we will explain the principles of how functions work in detail.
Last updated
In this section, we will explain the principles of how functions work in detail.
Last updated
Functions are a very useful and important tool when configuring Suvvy, allowing Suvvy to perform specific actions (invoke a knowledge base file, table, web-hook, etc.).
At the core of each Suvvy mechanism, where some action is required (in addition to responses), whether it's a knowledge base, tables, web-hooks, or something else, there lies a "function" responsible for its operation. Within a function, there are two parameters:
function name
function description
The name provides a general meaning, while the description is more detailed.
For example, for a table serving as a price list, which Suvvy needs to read to respond to a client, the function name and description might be:
Name:
price_table
Description: Used for providing product costs
This information gives Suvvy an idea of where the cost information is stored, so when a client asks, "How much does it cost?" Suvvy understands that this information is stored in the given table.
Note
There are more complex situations when calculations are done in multiple steps or when using information from different sources.
For example, when data first needs to be obtained from the first table, and then this information is passed to a second table to retrieve data according to this combination.
In this case, each table is assigned its own name and description.
For example, in the first table, we obtain the product category and its identifier (ID), and then, using the category ID, calculate the cost in another table, where the volume and cost of the product are specified. In this case, the parameters for the first table would be:
Name:
categories_table
Description: Used for obtaining product category IDs
For the second table:
Name:
price_table
Description: Used for obtaining product costs by ID.
At this point, one might wonder why not specify everything in one table right away? Here, it's divided simply as an example.
In this case, with such a scheme, we can specify a prompt in the instructions like this:
#COST CALCULATION
If the client requests the product cost, perform the following steps in order:
Obtain the product ID by calling the categories_table
function and passing the required product to it
Retrieve the product cost by calling the price_table
function and passing the product ID obtained in the previous step.
In English, the function call is phrased as call function .
Why are we calling two functions here? Doesn't the bot understand it from the description?
It does, but it's a matter of precision. If we want to increase it, it's better to explicitly state the sequence of steps in the instructions.
For calling functions in Suvvy's system instructions, the construction is used:
call function , where is the specific function.
Below are types of functions and examples of their use.
Pre-installed functions include the function for working with the knowledge base. When it's necessary to forcibly invoke a specific file in the knowledge base, the function is used:
get_file_text(""), where is the file name to search for in the Knowledge Base section.
For instance, if a client doesn't explicitly write that they want to connect with an operator, but in some cases, we want to reduce the chance that Suvvy won't call the correct file, we can use the following method:
In this case, Suvvy will call the file even though the client did not request to switch to a manager.
At present, custom functions include functions from the Tables and Actions sections.
Each table or action has its own unique function name and description. It is assigned individually for each separate table or action.
Functions themselves have descriptions, and Suvvy understands when they need to be called on its own.
Including functions in the instructions is not mandatory on its own, but we consider cases where the function call may be not obvious to the bot, or the sequence of actions has its branches that need to be described.
By analogy with the previous point, we can call necessary functions using the construction:
call function , where is the specific function.
For tables, having the word "table" in the name is mandatory (added automatically).
When calling a table or action, we must specify what we're passing to it to ensure Suvvy doesn't pass unnecessary information.
For example, if we want to call a web-hook that will contact the CRM and obtain information about a product, considering delivery to a specific city, we can create the instruction as follows: