Entity reference data
In JAICP, an entity is defined via a set of values that it can take. You can specify the values via synonyms or patterns.
Each value can be supplied with additional reference data in the string or JSON format by filling the DATA field.
Syntax
Assume that we have a city
entity. Let’s add synonyms for the city New York City to the directory: New York, Manhattan, The Big Apple.
In the DATA field, we can specify additional data in the JSON format: the official name of the city, country, and time zone.
{
"name": "New York City",
"country": "United States",
"timezone": "EST"
}
How to use
Let’s look at an example of an online store that sells vehicles.
Go to the NLU → Entities → My entities tab on the control panel and create a vehicle
entity with the following patterns:
(car*|vehicle*)
(bike*|bicycle*)
Then, in the DATA field for each pattern, add additional data in the JSON format: a unique product identifier and its normalized name.
-
For
(car*|vehicle*)
:{
"product_id": 1,
"unique_name": "car"
} -
For
(bike*|bicycle*)
:{
"product_id": 2,
"unique_name": "bicycle"
}
Now, let’s create the script. The user sends a message where they intend to buy a specific vehicle. The bot will:
- Display an order message using
$parseTree._vehicle.uniqueName
. - Make a HTTP request to
https://example.com/order
with a vehicle ID.
state: Start
q!: $regex</start>
a: Hello! Our store sells different types of vehicles. What do you want?
state: Vehicle
q!: i want to buy @vehicle
a: Okay, I’m ordering a {{$parseTree._vehicle.uniqueName}}!
script:
$http.post("https://example.com/order", { productId: $parseTree._vehicle.productId });