Conditions

Last Updated: 25.10.2019

Overview

A Skill node condition determines whether the node should be used in the conversation. If the condition of the skill node is satisfied, then Hala will enter the node.

The following diagram shows an example that uses conditions for a SAP Digital Assistant.

  1. The end-user asks for information about the balance in the backend system.

  2. Hala matches the user input with the intent intent.get_balance, and then search for the root nodes that include the condition intent.get_balance.

  3. Based on the response configuration in the founded node, Hala responds to the user and asks for additional information.

  4. The end-user responds "1000".

  5. Hala matches the user input with the entity.company_code_id, and searching for the child nodes that have the condition entity.company_code_id.

  6. Hala provides the response, "Please, provide the account ID".

  7. The end-user responds, "300001".

  8. Hala matches the user input with the entity.gl_id, and searching for the child nodes that have the condition entity.gl_id.

  9. After the system performs the necessary database queries, Hala provides the balance for the requested account.

Condition types

There are next types of the condition:

  • Intent. The intent is the simplest condition. The node is triggered if, after processing the user's input, Hala determines that the purpose of the user's input matches the intent. Use the syntax, intent.intent_name. For example, intent.reset_password checks if the user input is asking for a resetting password. If so, the node with the intent.reset_password intent condition is executed. You can find more information about the intents here Intents.

  • Entity. The node will be triggered if Hala detects the entity values in the user input. You can use the next syntax entity.incident_status to detect all the entity values in the user input. For example: entity.incident_status checks whether any of the statuses were detected in the user input. If the condition is met, the node will be executed. You can find more information about the entities here Entities.

  • Context. The node is triggered if the context variable specified in the condition is true. Use the syntax, context.variable_name. In many cases, the context variable in the condition is using when we need to evaluate the API response from the external application. For example, if you want to retrieve information from the SAP, for this, you need to create a node and specify the action (programmatic call into the external application), then you need to add at least a two child nodes with a context variable condition. In this case, one child node will have a condition context.SAP (in case of success), and the second child node will have condition context.SAP.error (in case of error). You can find more information about the entities here Context Variables.

  • RegEx. Additionally, in conditions, you can use regular expressions to build more sophisticated dialogs with your users. Use next syntaxes for RegEx: match input.text regex="your function". For example, if you want to execute the node in case the user input includes the word in capital letters, you can use the next regex match input.text regex="\b([A-Z]{3,})+\b".

  • System conditions. System conditions are available by default with the Hala platform. More details about the system conditions are available in the table below:

Condition syntax

Description

user.input

With this system condition, your node will accept any user input text. For example, if you asked the user to provide a description of the problem that the user has with the printer. In this scenario, you can not predict the problem for defining intent or entity or context, so in this case, you can use input.text to enter the node and then evaluate the problem.

out_of_scope

The system condition out_of_scope is preconfigured with different responses, like "I didn't get that. Can you say it again?". This system condition is matched when your user's input does not match any other conditions in other words, Hala will trigger the node with this condition for any unrecognized user input.

not_recognized

You can use it at the end of a list of nodes in your Skill or responses to catch any responses that did not match any of the previous conditions.

Adding condition

For adding the condition, you need to click on the condition field and then you will have two options:

First option. You can select from the dropdown list the need condition type:

And then select the needed value (additional values only available for the Intents and Entities):

If you choose "Context," then the system will enter into the field the prefix context. and you would need to add your context variable.

Second option. With the second option, you can enter the condition manually without using the dropdown list, you can start typing, and a dropdown list will be hidden.

Keep in mind that the system will recognize the conditions types described above. If you enter some text without using special prefix, the system will ignore that node.