1

The Watson Dialog Service on IBM Bluemix allows to create profile variables and to pass values to them. In the examples these variables always seem to have the type "TEXT" (see "myVariable" below). Are there any other types available? How would I pass a JSON object and how would I access specific values inside a dialog?

<variables>
    <var_folder name="Home">
        <var name="myVariable" type="TEXT"/>
    </var_folder>
</variables>
data_henrik
  • 16,724
  • 2
  • 28
  • 49

2 Answers2

1

Best to go to the documentation.

variables can be objects - consisting of many vars http://www.ibm.com/watson/developercloud/doc/dialog/reference_elements.shtml#reference_variables

vars can be of types http://www.ibm.com/watson/developercloud/doc/dialog/reference_elements.shtml#reference_var

chughts
  • 4,210
  • 2
  • 14
  • 27
  • It does not allow to handle JSON (from what I read). Nesting variable folders for scoping is also not possible as Watson complains about possible duplicate variable names. – data_henrik Jul 11 '16 at 10:42
1

I talked with the service team, and the recommendation is to use the new Watson Conversation service as it is actually possible to pass an array of name:value pairs. Below is a sample that the team came up with on the fly. Hopefully it's helpful.

Sample:

{
  "client_id": 4435,
  "name_values": [
  {
    "name": "string",
    "value": "string"
  }
  ]
}

For example, if you want to post to a context variable named JSON_object, the PUT context payload would be:

{
  "client_id": 4435,
  "name_values": [
  {
    "name": "JSON_object",
    "value": "{"sample":"data"}"
  }
  ]
}

HOWEVER, they highly recommend converting the JSON to flat XML before posting as context, since dialog has much more versatility to parse XML, using {variable_name.xmlElementName}.

More info found on the API explorer - https://watson-api-explorer.mybluemix.net/apis/dialog-v1#!/Profile/setProfile under PUT CONTEXT method.

joe
  • 2,468
  • 2
  • 12
  • 19