GitHubContribute in GitHub: Edit online

copyright: years: 2020 lastupdated: "2020-11-11"


Handling Watson Assistant response types

The SMS Gateway supports the following IBM Watson™ Assistant response types:

Each response type is specified by using a different set of JSON properties. The properties included for each response vary depending on the response type.

Note: The image, option, and suggestion response types were introduced in SMS Gateway 1.0.6.

Response type text

The text response type shows an ordinary text response.

{
  "output": {
    "generic": [
      {
        "response_type": "text",
        "text": "OK, you want to fly to Boston next Monday."
      }
    ]
  }
}

Response type image

The image response type shows an image.

{
  "output": {
    "generic":[
      {
        "response_type": "image",
        "source": "http://example.com/image.jpg"
      }
    ]
  }
}

You can use the image response in SMS Gateway to support sending multimedia messaging service (MMS) messages. The image response type is equivalent to the following smsActSendMedia action:

{
  "output": {
    "smsAction": {
          "command": "smsActSendMedia",
          "parameters":{
            "mediaURL": [
              "http://example.com/image.jpg"
            ]
         }  
      }
   }   
}

Response type suggestion

The suggestion response type is used by the disambiguation feature to suggest possible matches when it isn’t clear what the user wants to do.

When disambiguation is enabled, your assistant asks the customer for help when more than one dialog node can respond to a customer's input. Instead of guessing which node to process, your assistant shares a list of the top possible nodes with the user, and asks the user to pick the right one.

More more information, see Disambiguation.

Possible matching dialog nodes are listed using a suggestion response:

{
  "output": {
    "generic": [
      {
        "response_type": "suggestion",
        "title": "Please choose one of the following options:",
        "suggestions": [
          {
            "label": "I'd like to order a drink.",
            "value": {
              "intents": [
                {
                  "intent": "order_drink",
                  "confidence": 0.7330395221710206
                }
              ],
              "entities": [],
              "input": {
                "suggestion_id": "576aba3c-85b9-411a-8032-28af2ba95b13",
                "text": "I want to place an order"
              }
            },
            "output": {
              "text": [
                "I'll get you a drink."
              ],
              "generic": [
                {
                  "response_type": "text",
                  "text": "I'll get you a drink."
                }
              ],
              "nodes_visited_details": [
                {
                  "dialog_node": "node_1_1547675028546",
                  "title": "order drink",
                  "user_label": "I'd like to order a drink.",
                  "conditions": "#order_drink"
                }
              ]
            },
            "source_dialog_node": "root"
          },
          {
            "label": "I need a drink refill.",
            "value": {
              "intents": [
                {
                  "intent": "refill_drink",
                  "confidence": 0.2529746770858765
                }
              ],
              "entities": [],
              "input": {
                "suggestion_id": "6583b547-53ff-4e7b-97c6-4d062270abcd",
                "text": "I need a drink refill"
              }
            },
            "output": {
              "text": [
                "I'll get you a refill."
              ],
              "generic": [
                {
                  "response_type": "text",
                  "text": "I'll get you a refill."
                }
              ],
              "nodes_visited_details": [
                {
                  "dialog_node": "node_2_1547675097178",
                  "title": "refill drink",
                  "user_label": "I need a drink refill.",
                  "conditions": "#refill_drink"
                }
              ]
            },
            "source_dialog_node": "root"
          }
        ]
      }
    ]
  }
}

Each suggestion includes a label that can be displayed to the user and a value that specifies the input to send to the assistant if the user chooses the corresponding suggestion. By default, SMS Gateway adds a number to the text specified in a label. The suggestions are numbered sequentially and are displayed to the user in the order in which they appear in the list. The user can type a number to choose one of the suggestions.

You can configure the text that will be prepended to each label using the smsActSetDisambiguationConfig action. In the prefixText attribute, use %s to represent the number corresponding to the suggestion; this is replaced with the actual number at run time.

{
  "output": {
    "smsAction": {
      "command": "smsActSetDisambiguationConfig",
      "parameters": {
        "prefixText": "%s."
      }
    }
  }
}

For example, if label is configured as follows:

"label": "I'd like to order a drink."

By default, SMS Gateway sends this to the user:

1. I'd like to order a drink.

If prefixText is set to Enter %s for:, SMS Gateway sends the following output to the user

Enter 1 for: I'd like to order a drink.

The list of suggestions is introduced using the text specified by the title attribute of the suggestion response.

Note: If a configuration is specified using the smsActSetDisambiguationConfig action, the same settings are used each time disambiguation is triggered. Specify this action in a root node.

Response type option

The option response type allows the user to select from a list of options, and then sends input to the assistant based on the selected option:

{
  "output": {
    "generic": [
      {
        "response_type": "option",
        "title": "Available options",
        "description": "Please select one of the following options:",
        "preference": "button",
        "options": [
          {
            "label": "Option 1",
            "value": {
              "input": {
                "text": "option 1"
              }
            }
          },
          {
            "label": "Option 2",
            "value": {
              "input": {
                "text": "option 2"
              }
            }
          }
        ]
      }
    ]
  }
}

SMS Gateway uses the same numbering approach that is used for a suggestion response in the option response. Like with a suggestion response, you can change the default text to prepend to each label by using the smsActSetOptionsConfig action.

First the value specified in the title attribute is displayed to the user. Then, the text specified in the label attributes.

{
  "output": {
    "smsAction": {
      "command": "smsActSetOptionsConfig",
      "parameters": {
        "prefixText": "%s."
      }
    }
  }
}

When the smsActSetOptionsConfig is specified, the same settings are used for all option responses.