How do I pass response values from extension to custom response type in IBM Watson Assistant chat?

Viewed 71

The below JSON defines custom response for the client to allow custom UI. As per the documentation https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-response-types-reference#user_defined I can define "anything" for the "user_defined" object but I am failing to understand how to pass the variable as provided by my extension response.

{
  "generic": [
    {
      "user_defined": {
        "default_color": "blue",
        "template_name": "color_picker",
        "my_response_value": "???"
      },
      "response_type": "user_defined"
    }
  ]
}
1 Answers

So after some trial and error it seems that it works with the expression lang as described here https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-call-extension#extension-check-status

For example

{
  "generic": [
    {
      "user_defined": {
        "default_color": "blue",
        "template_name": "color_picker",
        "my_second_value": "${step_170_result_1.body.base_code}"
      },
      "response_type": "user_defined"
    }
  ]
}

Here the property "my_second_value" will be replaced by the value from the "session variables/extension response". Your reference will differ in the step value and result value.

Related