简体   繁体   English

Webhook 与 Watson Assistant 的集成?

[英]Webhook integration with Watson Assistant?

I want to know whether IBM Watson Assistant has the feature of calling webhook.我想知道IBM Watson Assistant 是否有调用webhook 的功能。

It means when an intent of workspace is matched Watson Assistant need to send a post request to an external server including the intent in the request body.这意味着当工作区的意图匹配时,Watson Assistant 需要向外部服务器发送一个 post 请求,在请求正文中包含该意图。

Example for a webhook:网络钩子示例:

https://123.456.789.12:7788/myWebhook/testMethod https://123.456.789.12:7788/myWebhook/testMethod

IBM Watson Assistant need to send a Post request to this service and that service will return a text string. IBM Watson Assistant 需要向该服务发送 Post 请求,该服务将返回一个文本字符串。 Watson Assistant should get that text and show it to the user. Watson Assistant 应该获取该文本并将其显示给用户。

That is my usecase.那是我的用例。 Will it work with Watson Assistant?它可以与 Watson Assistant 一起使用吗?

i found the below documentation from IBM site.我从 IBM 网站找到了以下文档。 https://console.bluemix.net/docs/services/conversation/dialog-actions.html https://console.bluemix.net/docs/services/conversation/dialog-actions.html

It says to update the json response.它说要更新 json 响应。 ie add another key value pair to json object as "action".即向 json 对象添加另一个键值对作为“动作”。 in the action json array there is "name" parameter.在动作 json 数组中有“名称”参数。 I added above url to name parameter and checked by calling the intent whether a request comes to my web service but it didn't.我将上面的 url 添加到 name 参数并通过调用意图检查请求是否到达我的 Web 服务,但它没有。

following is my json response.以下是我的 json 响应。 i assumed once the intent is matched a post request should go to my web service.我假设一旦意图匹配,发布请求应该转到我的 Web 服务。 but i checked my web service by printing the request body on the console.但我通过在控制台上打印请求正文来检查我的网络服务。 but no any request came to it.但没有任何要求。 could you please tell me where did i miss?你能告诉我我错过了哪里吗?

{
  "context": {
    "skip_user_input": true
  },
  "output": {
     "text": {
        "values": [
             "your current outstanding balance is $my_balance ."
        ],
     "selection_policy": "sequential"
    }
  },
  "actions": [
     {
       "name": "https://123.456.789.12:7788/myWebhook/testMethod",
       "type": "client",
       "parameters": {
           "body": "$body"
       },
      "result_variable": "context.my_balance"
     }
  ]
 }

You found the correct method, ie dialog actions, to implement webhooks.您找到了实现 webhook 的正确方法,即对话操作。

Watson Assistant supports server- or client-side actions: Watson Assistant 支持服务器端或客户端操作:

  • For the server-side action you would set up an action with IBM Cloud Functions.对于服务器端操作,您将使用 IBM Cloud Functions 设置操作。 That action would call the webhook.该操作将调用 webhook。
  • For client side, you would pass the information similar to what you show in the question to the app (client).对于客户端,您会将类似于您在问题中显示的信息传递给应用程序(客户端)。 Your app would need to react and to call the webhook.您的应用需要做出反应并调用 webhook。

From what I read about your case I recommend checking out the server-side action.根据我对您的案例的了解,我建议您查看服务器端操作。 This tutorial about a database-driven bot implements a couple of those actions . 这个关于数据库驱动机器人的教程实现了其中的几个操作 Instead of calling the database, you would call out the webhook.您可以调用 webhook,而不是调用数据库。

截至 2019 年 8 月,Watson Assistant 中现已集成了 Webhook 功能

Go to "Options" in the Assistant dialog and enable webhook.转到“助手”对话框中的“选项”并启用 webhook。 Paste the url you got after creating an action from cloud functions.粘贴从云函数创建操作后获得的 url。 Don't forget to add ".json" to the url you paste in the assistant webhook page.不要忘记将“.json”添加到您粘贴到助手 webhook 页面中的 url。 See more information here: https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks在此处查看更多信息: https : //cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM