简体   繁体   中英

Watson Conversation: Show user all entities

In Watson conversation. I have an entity Fruit

Fruit values:
    -Apple     
    -Orange
    -Banana
    -Kiwi

I'd like to create a new dialog where the intent of the user is to get a list of all the values of a specific entity, in this case a list of all the fruits, . So the conversation should go:

User: "What fruits do you have?"

And then I'd like Watson to respond

Watson: "The fruits we got in store are: Apple, Orange, Banana, Kiwi"

All the stuff I found is of recognizing an entity in users input, such as

User: "Do you have apples?"

And Watson picking up Apples

Just to clarify , setting an array with the possible options declarativly on a context variable as shown below is no good for me, I need to get them dynamically from the entity

{
  "context": {
    "fruits": [
      "lemon",
      "orange",
      "apple"
    ]
  },
  "output": {
    "text": {
      "values": [
        "This is the array: <? $fruits.join(', ') ?>"
      ],
      "selection_policy": "sequential"
    }
  }
}

Thankss!

AFAIK it is not possible to directly access the workspace metadata from within a dialog. You have access to what was detected using the intents, entities and context variables. However, I see two options you have:

  1. Use your application program that drives the chat to access the entity definitions on the fly, then create a context variable in which you offer the entity choices. The API to list entities can be used from any programming language and there are SDKs.
  2. With a relatively new feature you can invoke server or client actions from within a dialog node , ie, make programmatic calls. Use that and the API mentioned above to obtain the list of entity values.

.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM