Conditions

This object is responsible for the validation of value according to configured conditions.

Contain

Condition that matches if value contains one of the values present in values.
This condition is case insensitive.

Examples :

  • contains("hello, how are you?", ["hell"])
  • contains("hello, how are you?", ["Hello"])
  • contains("hello, how are you?", ["bye", "hello"])
  • contains("hello, how are you?", ["bye"])
AttributeTypeRequiredDescription
typestringalways contains
valuesarraya list strings that should match the value
{
    "type": "contains",
    "values": ["hello"]
}

Equal

Condition that matches if value equals the expected one.
This condition is case sensitive.

Examples :

  • equals("hello", "hello")
  • equals("hello, how are you?", "hello")
  • equals("hello", "Hello")
  • equals("hello", "bye")
AttributeTypeRequiredDescription
typestringalways match_intent
expectedstringexpected value
{
    "type": "equals",
    "expected": "hello"
}

Match intent

Condition that matches if the intent is detected in the value.

AttributeTypeRequiredDescription
typestringalways match_intent
intent.idstringintent ID to detect
intent.namestringintent name to detect
intent.typestringalways intent
{
    "type": "match_intent",
    "intent": {
        "id": "c1c1c1c1c1c1c1c1c1c1c1c1",
        "name": "an intent",
        "type": "intent"
    }
}

Match regexp

Condition that matches if value matches a regular expression.

Examples :

  • matches("hello", /hello/)
  • matches("hello 12", /\d+/)
  • matches("hello", /\d+/)

📘

Store matched pattern

If you want to store a matched pattern in a session value, it is easily possible. Just follow this tutorial.

AttributeTypeRequiredDescription
typestringalways match_regexp
patternstringa valid regular expression pattern
{
    "type": "match_regexp",
    "pattern": "[\w]+"
}

Is set

Condition that matches if value is not null.

Examples :

  • is_set("hello")
  • is_set(null)
AttributeTypeRequiredDescription
typestringalways is_set
{
    "type": "is_set"
}

Is not set

Condition that matches if value is null.

Examples :

  • is_not_set(null)
  • is_not_set("hello")
AttributeTypeRequiredDescription
typestringalways is_not_set
{
    "type": "is_not_set"
}

Is number

Condition that matches if value is a number.
Floats can have . or a , as delimiter.

Examples :

  • is_number("1.3")
  • is_number("1")
  • is_number("1,3")
  • is_number("hello")
AttributeTypeRequiredDescription
typestringalways is_number
{
    "type": "is_number"
}

Is less than

Condition that matches if value is less than another number.

Examples :

  • is_less_than("12.3", 100)
  • is_less_than("12,3", 100)
  • is_less_than("12", 100)
  • is_less_than("12", 1)
  • is_less_than("12", 12)
AttributeTypeRequiredDescription
typestringalways is_less_than
maximumnumbermaximum value
{
    "type": "is_less_than",
    "maximum": 10
}

Is less than or equal

Condition that matches if value is less than or equal to another number.

Examples :

  • is_less_than_or_equal("12.3", 100)
  • is_less_than_or_equal("12,3", 100)
  • is_less_than_or_equal("12", 100)
  • is_less_than_or_equal("12", 12)
  • is_less_than_or_equal("12", 1)
AttributeTypeRequiredDescription
typestringalways is_less_than_or_equal
maximumnumbermaximum value
{
    "type": "is_less_than_or_equal",
    "maximum": 10
}

Is greater than

Condition that matches if value is greater than another number.

Examples :

  • is_greater_than("12.3", 10)
  • is_greater_than("12,3", 10)
  • is_greater_than("12", 10)
  • is_greater_than("12", 12)
  • is_greater_than("12", 100)
AttributeTypeRequiredDescription
typestringalways is_greater_than
maximumnumbermaximum value
{
    "type": "is_greater_than",
    "maximum": 10
}

Is greater than or equal

Condition that matches if value is greater than or equal to another number.

Examples :

  • is_greater_than_or_equal("12.3", 10)
  • is_greater_than_or_equal("12,3", 10)
  • is_greater_than_or_equal("12", 10)
  • is_greater_than_or_equal("12", 12)
  • is_greater_than_or_equal("12", 100)
AttributeTypeRequiredDescription
typestringalways is_greater_than_or_equal
maximumnumbermaximum value
{
    "type": "is_greater_than_or_equal",
    "maximum": 10
}