简体   繁体   中英

IBM Watson Conversation: How to capture and retrieve a list of values in a variable

I have a dialog where users can enter one or more country names. How do I retrieve the values from the entity defined to store the responses.

Example : Entity : Country

Question : Where did you travel to?
Answer : Africa, Thailand and China.

How can I capture these 3 values in a list entity?

Henrik is right, just to add to that, What he said will return them in an array, if you do

"countries": "<? entities['sys-location'] .toString() ?>"

you will get a comma separated list of the locations returned.

@sys-location entity in System Entities extracts location from the conversation. (Note: Ensure that you have switched on that entity as shown below)

在此处输入图片说明

You can now see that location has been extracted from conversation

在此处输入图片说明

You can use the system entity for locations, @sys-location . You need to turn that capability on for your workspace. See the wizard for entity creations.

In your dialog node where you want to capture the input in a list, you can assign those countries to a context variable . Switch to the JSON editor to edit variables. Then do something like:

"context": {
    "countries": "<? entities['sys-location'] ?>"
  },

See my collection of examples for context processing for something similar.

Its Quite Simple. Use

"countries": "@sys-location.values"

It will list all @sys-location values in array form.

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