【问题标题】:IBM Watson: How do I add a hyperlink to Watson Responses?IBM Watson:如何向 Watson 响应添加超链接?
【发布时间】:2018-08-04 17:29:59
【问题描述】:

我尝试了其他论坛上提到的其他回复,但我仍然无法获得正确的结果。

截至目前,this is what the layout looks like

任何帮助将不胜感激!

【问题讨论】:

    标签: json watson-conversation watson


    【解决方案1】:

    在您的 Watson 响应中添加 HTML 标记,浏览器将呈现:

    The link to go to google is: click <a  target="_blank" href="https://google.com.br">Google</a>.<br/><br/>
    

    添加内部 Watson 响应:

    测试超链接:

    Obs.: Check inside 试试看,这不起作用,但在您的 Web 应用程序中,一切都会正常工作。这对其他&lt;html&gt;标签有效,例如:&lt;button&gt;

    我回答了同样的问题here。 回答更多细节和图片here

    【讨论】:

    • 是来自 Watson Virtual Agent 的输出还是您自己的自定义聊天界面?我正在虚拟代理中尝试它,但我无法让它显示为超链接 - html 标记本身显示
    • 本例中,我的自定义聊天界面,网页。取决于您的频道是什么,例如 messenger,仅当您直接发送 https://yourwebsite.com 时链接才有效
    • 好的,很高兴知道。到目前为止我所经历的是,Watson Virtual Agent 不会将它们显示为链接
    • 你在response我的例子中添加了吗?尝试仅使用带有链接标记的&lt; a href&gt;&lt;/a&gt;
    • 我做到了。 Watson 虚拟代理小部件不会将其显示为链接
    【解决方案2】:

    将链接周围的“引号”替换为“撇号”

    {
      "output": {
        "text": {
          "values": [
            "say something <a href='http://www.website.com/'>link text</a>"
          ],
          "selection_policy": "sequential"
        }
      }
    }
    

    【讨论】:

      【解决方案3】:

      你需要通过context传递超链接

      示例(在后端使用 python)-

      response['context']['link'] = "www.google.com"
      conversation.message(workspace_id=workspace_id,
          message_input={'text': user_input},
          context=response['context'])
      

      现在在您的对话框中

      {
        "context": {},
        "output": {
          "text": {
            "values": [
              "$link"
            ],
            "selection_policy": "sequential"
          }
        }
      }
      

      所以你传入context的值显示前缀$

      【讨论】:

      • 链接可以直接添加到 watson 对话响应中
      猜你喜欢
      • 1970-01-01
      • 2019-06-01
      • 1970-01-01
      • 2017-08-01
      • 2018-10-12
      • 1970-01-01
      • 2020-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多