How to setup a complicated 'IsList' parameter in Dialogflow

回眸只為那壹抹淺笑 提交于 2020-02-06 10:03:34

问题


I'm looking at this link:

Actions and parameters | Dialogflow Documentation | Google Cloud

Where it explains 'List parameters' it uses these examples:

  • "I want apples"
  • "I want apples and oranges"
  • "I want apples, oranges, and bananas"

Then I was wondering if it's possible to set up a 'List parameter' to handle something like this:

"I want 7 apples, 8 oranges and 12 bananas"

So you'd have a sort of Key - Value pair list.

Pseudo code:

List<KeyValuePair<string, int>> fruitList = new List<KeyValuePair<string, int>>();

KeyValuePair<string, int> applesItem = new KeyValuePair<string, int>("apples", 7);
KeyValuePair<string, int> orangesItem = new KeyValuePair<string, int>("oranges", 8);
KeyValuePair<string, int> bananasItem = new KeyValuePair<string, int>("bananas", 12);

fruitList.Add(applesItem);
fruitList.Add(orangesItem);
fruitList.Add(bananasItem);

So, in dialogflow, the $FruitList parameter would be something like the Key - Value pair list fruitList above.

The number part should then match with the @sys.cardinal entity. And the fruit part should match to a custom entity @Fruits with a bunch of fruits in it.

Pseudo code: List<KeyValuePair<@sys.cardinal, @Fruits>>

How can I make an 'Intent' in Dialogflow that can do this? Is it possible?

Help / Advice appreciated.


回答1:


Im not sure if you could get dialogflow return a key value pair object, but using composite entities you can create an entity which consists of an amount (number) and a fruit (fruit entity). You could call this composite entity order and make that a list in the parameters in your intent. When you enter

"I want 7 apples, 8 oranges and 12 bananas"

You should get a list with 3 order entities ( 7 apples, 8 oranges, 12 bananas)

https://cloud.google.com/dialogflow/docs/entities-developer#developer_composite



来源:https://stackoverflow.com/questions/57855562/how-to-setup-a-complicated-islist-parameter-in-dialogflow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!