Search code examples
ibm-cloudibm-watsonwatson-dialog

How to retrieve specific profile variables from Watson's Dialog service via the watson-developer-cloud library


When retrieving profile variables from Watson's Dialog service, there is a parameter called name which allows you to control which variables are retrieved. If this parameter is blank, all variables that are associated with the specified client_id are returned. Otherwise, only the specified variables in name are returned.

I finally figured out how to specify more than one variable name on a direct GET to the REST API (give them all the same name, like &name=var1&name=var2), but I can't figure out how to do this via the watson-developer-cloud library. It seems that no matter how I specify names in the dialog.getProfile() function call, it always returns all of the variables.

Can someone tell me how to do this? I don't want to fetch them all every time and then search them for the one I want.


Solution

  • There was a bug in the library that was preventing name from being sent to the service.

    Please update the library by doing

    npm install watson-developer-cloud
    

    And try with the example below

    var params = {
      dialog_id: '<dialog id here>',
      client_id: '<client id here>',
      name: ['var1', 'var2']
    };
    
    dialog.getProfile(params, function(err, response){
      console.log(response)
    });