Fabio Ebner
Fabio Ebner

Reputation: 2783

Watson conversation list entity value

In Watson Conversation when I create a dialog, can I list the values of my Entity?? for sample I have one entity fruits (apple, orange, and etc) so in one of my responses can I list the content of @fruits??

tks

Upvotes: 0

Views: 1866

Answers (1)

Sayuri Mizuguchi
Sayuri Mizuguchi

Reputation: 5330

For access intents and entities, first, your user need to request something for calling this objects... And in this case, your application will access:

  • Name of entity (@fruits);
  • The value of your entity typed from your user

Your app will show Fruit:orange if you user type orange, and Watson will recognize the entity and the value and save inside entities.fruit[0], not all values from your entity inside @fruits, like this.

Access entity: IBM Official Documentation.

Anyway: I think you want all values. Right?

I guess that best form is using context variables to save all "fruits" and show like:

For this Dialog runtime context:

{
  "context": {
    "toppings_array": ["orange", "apple"]
  }
}

Update:

{
  "context": {
    "toppings_array": "<? $toppings_array.append('banana', 'melon') ?>"
  }
}

Result:

{
  "context": {
    "toppings_array": ["orange", "apple", "banana", "melon"]
  }
}

Show for the user:

{
  "output": {
    "text": "This is the array: <? $toppings_array.join(', ') ?>"
  }
}

All JSON Example:

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

Result:

This is the array: lemon, orange, apple

enter image description here

See the official example from Official Documentation.

Upvotes: 1

Related Questions