Search code examples
ibm-cloudibm-watsonwatson-dialog

What types are available for profile variables in Watson Dialog Service?


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>

Solution

  • 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.