DLim
DLim

Reputation: 1

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?

Upvotes: 0

Views: 572

Answers (4)

Rohit
Rohit

Reputation: 187

Its Quite Simple. Use

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

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

Upvotes: 0

Mitch
Mitch

Reputation: 849

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.

Upvotes: 1

data_henrik
data_henrik

Reputation: 17118

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.

Upvotes: 0

RiyaMRoy
RiyaMRoy

Reputation: 330

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

enter image description here

You can now see that location has been extracted from conversation

enter image description here

Upvotes: 0

Related Questions