Language conditions

Teneo can use language conditions to verify if an input of a user matches certain linguistic criteria. For example, a language condition used in a syntax trigger of a flow makes sure the flow is triggered when the user's input matches the criteria in the language condition. Or if a transition inside a flow contains a language condition, then Teneo will only traverse the transition when the input matches the language condition of the transition.

You may have already seen how language conditions were used in these places:

  • Syntax triggers - A flow will be executed if the user input matched the language condition in the syntax trigger of the flow
  • Transitions - A transition in a flow is only traversed if the user input matched the condition in the transition
  • Listeners - The 'operation' script of a listener is only executed if the user input matched the condition in the listener

Condition syntax introduction

The most common elements that make up a language condition are:

For example, the following language condition contains 3 language objects and 2 operators:


Let's dissect this language condition.

The language objects used in the example above are:

    This is a reference to a Lexical Language Object (note the extension .LEX) in the Teneo Lexical Resources. Lexical language objects just cover the different inflections of a word, as well as spelling and regional variations. In this case, the language object contains baggage/baggages/baggage's/baggages'
    This is also a reference to a Lexical Language Object. In this case, the language object contains baby/babies/baby's/babies'
    This is a reference to a Synonym (SYN) object. Synonym objects cover synonyms of a word, usually by referencing other language objects. In this case, the language object contains (%CHILD.NN.LEX / %KID.NN.LEX / %JUVENILE.NN.LEX / %MINOR.NN.LEX / %OFFSPRING.NN.LEX / %INFANT.NN.SYN) (you may have noticed that the contents of language objects are language conditions too!)

The example condition contains the following operators:

  • &
    This is the AND operator. Both the expression before and after the AND operator should match for the condition to be true, regardless of the word order in the user input.
  • /
    This is the OR operator. Either the expression before or after OR operator needs to match for the condition to be true.

In the example condition above we also use parentheses ( ). Parentheses are used to group expressions belonging together. In the example above, this means that the condition will only match if the input contains the word 'baggage' and the word 'baby' or if the input contains the word 'baggage' and a synonym of 'child'.

Based on this information we can determine that this condition will match on:

  • 'How much baggage can I bring for my baby?'
  • 'What is the baggage allowance for a child?'
  • 'Can a minor bring baggage on the plane?'

All inputs above contain at least the word 'baby' or a synonym of 'child' and they also contain the word 'baggage'.

The condition above will not match on the following inputs:

  • 'What is the luggage allowance for a child?'
  • 'Can an adult bring baggage on the plane?'
  • 'What is the weather like in Barcelona?'

The first input contains the word 'luggage', but that is not part of the language object for 'baggage' (%BAGGAGE.NN.LEX). The second input contains 'baggage' but not a synonym of 'child' or the word 'baby'. The last example does not match any of these words.

Condition components

The introduction above highlights a few of the core elements of a language condition, but there are many more components you can use to create your condition. The following list contains the elements that you can use and links to pages with more details:

  • Operators
    The example above already introduced two operators, but to get precise control on what to match there are many more operators you can use. For more details, read the Condition Syntax Reference.
  • Language objects
    As outlined above, language objects capture words, synonyms or various ways of expressing the same (partial) intent. More details can be found on the Language Objects page. Teneo provides Lexical Resources that contain many pre-defined language objects.
  • Annotations
    Annotations can be considered 'labels' that are attached to inputs. They are mostly attached to an input using machine learned models. You can use annotations in language conditions in a similar way as language objects. For more information please read the Annotations page.
  • Script conditions
    You can use Groovy scripts in conditions too. For a Script condition to be fulfilled, the result of the expression has to be true. More details can be found in the script-condition paragraph of the Condition Syntax Reference.
  • Attached scripts
    A language condition's primary goal is to make sure an input matches certain linguistic criteria. However, you can also include attached scripts in a language condition. The purpose of attached scripts in a condition is not so much to make sure that an input matches certain criteria, but to extract information from an input. An input may contain a city or product name that you may want to remember and use, and attached scripts can be used to extract them. More details can be found on the attached scripts page.

Setting an 'unused words' limit

Normally, a language condition only specifies which words must be present in an input. There may be other words in the input, not accounted for by the condition, and the input will still match the condition. Let's take a symplistic condition like what + date + is + it. This conditon will match both 'What date is it?' and 'What date is it tomorrow?'

Sometimes however, you want your condition to be very exact and not match if the users input contains words that were not specified in the condition at all. With 'Limit unused words' you can add restrictions on how many words besides those specified in the condition may be present in the user input.

Limit unused words

More details on how to work with unused words can be found in the condition syntax reference and an example usage is illustrated on the create a custom order group page.

Was this page helpful?