API.AI developer composite entity definition and Json results

735 Views Asked by At

I am trying to address use cases of users stating what they want to buy/rent , i.e: I want to buy a car, I want to rent a car, I want to buy a house,I want to rent a house. I created entity named "action" (buy , rent) and entity named "subject" (car , house). I then create a composite entity of action-subject like this (same as in the tutorial - I thought) -

@action:action action @subject:subject subject 
@subject:subject subject
@action:action action

When I try to define intent based on user input like: "I want to buy a car" , I get the 2 entities of "action" and "subject" instead of getting the entity of "action-subject". Even if I manually mark the "buy a car" and turn it into the entity of "action-subject", when I test and check the JSON, I see that I get the "action" data correctly, but missing the "subject" data - see relevant Json...

"parameters": {
"action-subject": {
"action": "buy"
}

what I want to get actually, is:

"parameters": {
"action-subject": {
"action": "buy",
"subject": "car"
}

What am I doing wrong? or maybe I am approaching it wrongly and I should not use composite entities based on 2 developer entities but rather 1 developer entity and 1 @sys entity?

1

There are 1 best solutions below

1
On BEST ANSWER

What you should do is create two entities

  • Action with buy and rent
  • Subject with car and house

entities

Then create a intention as follows:

intent

You can see how the parameters to be captured by the api.ai as desired.

The parameter JSON will look like below:

"parameters": {
      "action": "rent",
      "Subject": "car"
    }