Skip to main content

$entities

The $entities variable contains the list of all CAILA entities recognized in the user request.

Object format

The value of this variable is an array of objects having the following structure:

[
{
"pattern": "fruit",
"startPos": 1,
"length": 1,
"value": "{\n \"name\": \"banana\",\n \"type\": \"fruit\"\n}"
}
]
  • pattern — the entity name.

  • startPos — the position of the word from which the entity starts. The numbering starts from zero.

  • length — the number of tokens that make up the entity.

  • value — the entity reference data (DATA).

    caution
    The value always has a string type, even if you have specified JSON in DATA. Use the JSON.parse method in the script to convert a string into an object and access its properties.

If the user request matches an intent with slot filling, the objects in the $entities array will have an additional slot property — the name of the slot matched by the entity.

How to use

state: DebugEntities
q!: *
if: $entities.length
a: Your request has the following entities: {{_.pluck($entities, "pattern").join(", ")}}.
else:
a: There are no entities in the request.