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.
Response type search
The search
response type returns a list of search results from a search skill. The response includes an introductory header and an array of search results:
{
"output": {
"generic": [
{
"response_type": "search",
"header": "I found the following information that might be helpful.",
"results": [
{
"title": "About",
"body": "IBM Watson Assistant is a cognitive bot that you can customize for your business needs, and deploy across multiple channels to bring help to your customers where and when they need it.",
"url": "https://cloud.ibm.com/docs/assistant?topic=assistant-index",
"id": "6682eca3c5b3778ccb730b799a8063f3",
"result_metadata": {
"confidence": 0.08401551980328191,
"score": 0.73975396
},
"highlight": {
"Shortdesc": [
"IBM <em>Watson</em> <em>Assistant</em> is a cognitive bot that you can customize for your business needs, and deploy across multiple channels to bring help to your customers where and when they need it."
],
"url": [
"https://cloud.ibm.com/docs/<em>assistant</em>?topic=<em>assistant</em>-index"
],
"body": [
"IBM <em>Watson</em> <em>Assistant</em> is a cognitive bot that you can customize for your business needs, and deploy across multiple channels to bring help to your customers where and when they need it."
]
}
}
]
}
]
},
"context": {
"global": {
"system": {
"turn_count": 1
},
"session_id": "58e1b04e-f4bb-469a-9e4c-dffe1d4ebf23"
}
}
}
For a search response, SMS Gateway sends the introductory text specified by the header
property, followed by the body
text from the search result with the highest confidence
score. For the above example,
SMS Gateway sends the following to the user:
I found the following information that might be helpful. IBM Watson Assistant is a cognitive bot that you can customize for your business needs, and deploy across multiple channels to bring help to your customers where and when they need it.
If the results
array contains more than one search result, only the result with the highest confidence score is used.
Note: Only the text of the body
field is sent to the user. Make sure the search skill configuration maps the body
field to the text you want to be included in the response sent to the user.