首页 > 解决方案 > IBM Watson Assistant / Conversation:输出显示最后一次搜索

问题描述

我已经开发了云功能,并且正在使用带有图像响应类型以及文本的“通用输出”。但是,当我搜索产品(使用我的云功能)时,会出现最后一个结果。

例如:

我:现在买经典

机器人:名称:经典,价格:4.99,描述:经典描述

但是当我搜索另一种产品时

我:现在买额外的

机器人将显示

机器人:名称:经典,价格:4.99,描述:经典描述

只有在另一个搜索实例之前,它才会刷新并显示正确的结果。

{
  "context": {
    "name": "",
    "counter": 0
  },
  "output": {
    "generic": [
      {
        "values": [
          {
            "text": "Found  Products"
          }
        ],
        "response_type": "text",
        "selection_policy": "sequential"
      },
      {
        "title": "<? $result.body.items[0].name ?>",
        "source": "http://**********/pub/media/catalog/product<? $result.body.items[0].custom_attributes[5].value ?>",
        "description": "$<? $result.body.items[0].price ?>",
        "response_type": "image"
      },
      {
        "title": "Select one of the following options",
        "options": [
          {
            "label": "Order a subscription",
            "value": {
              "input": {
                "text": "Order a subscription"
              }
            }
          },
          {
            "label": "More Details",
            "value": {
              "input": {
                "text": "More Details"
              }
            }
          }
        ],
        "response_type": "option"
      }
    ]
  },
  "actions": [
    {
      "name": "/**********@gmail.com_dev/getProducts2",
      "type": "server",
      "parameters": {
        "url": "<?entities.products[0].literal?>"
      },
      "credentials": "$my_creds",
      "result_variable": "context.result"
    }
  ]
}

标签: ibm-cloudwatson-conversationibm-cloud-functions

解决方案


找到了答案。我将输出文本放在子节点而不是父节点中。无需删除任何上下文变量。


推荐阅读