2
votes

I'm working with Watson Conversation, inside a dialog. I want to return all values of one entity in an array context variables.

The following works

{
"context": {
    "toppings_array":["@toppings[0]","@toppings[1]"] works.
    ...
}

I'd like to find a generic solution, such as

{
"context": {
    "toppings_array":["@toppings"]
    ...
}

The above sample sets the toppings_array value to the first element of the entity (e.g. @toppings[0]).

Thx.

2

2 Answers

1
votes

You can do the following:

{
"context": {
    "toppings_array": "<? entities['toppings'] ?>"
    ...
}

You would end up with something like:

[
  {
    "entity": "toppings",
    "location": [
      4,
      13
    ],
    "value": "pepperoni",
    "confidence": 1
  },
  {
    "entity": "toppings",
    "location": [
      14,
      23
    ],
    "value": "sprinkles",
    "confidence": 1
  }
]
0
votes

Just Use @ Topping.values . It will return all the values in form of array in context variable.