简体   繁体   English

Watson助理程序设计Heroku webhook无法正常工作

[英]Watson Assistant programmatic to Heroku webhook not working

I have created a Webhook ( https://moviebotdf.herokuapp.com/get-movie-details ), it is tested with postman and dialogflow and working properly. 我创建了一个Webhook( https://moviebotdf.herokuapp.com/get-movie-details ),它使用postman和dialogflow进行测试并正常工作。

I want to integrate it with IBM Watson Assistant via programmatic call, but this is not returning anything (ie the output is ""). 我想通过编程调用将它与IBM Watson Assistant集成,但这不会返回任何内容(即输出为“”)。

I checked the IBM support ( https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-actions&locale=en ) and also other solutions as calling a function that could call the webhook but I am having even less succcess there. 我检查了IBM支持( https://cloud.ibm.com/docs/services/assistant?topic=assistant-dialog-actions&locale=en )以及其他解决方案,因为它调用的函数可以调用webhook但我甚至有那里不太成功。 As I understand from the support, a direct call from the Assistant to the Webhook should be possible (and easier for newbies like me), hence is the solution I seek. 正如我从支持中理解的那样,从助手到Webhook的直接调用应该是可能的(对于像我这样的新手来说更容易),因此是我寻求的解决方案。 Code in the Assistant is as follows: 助手中的代码如下:

{
  "context": {
    "skip_user_input": true,
    "prodname": "$prodname"
  },
  "output": {
     "text": {
        "values": [
             "$dataToSend"
        ],
     "selection_policy": "sequential"
    }
  },
  "actions": [
     {
       "name": "https://moviebotdf.herokuapp.com/get-movie-details",
       "type": "client",
       "parameters": {
           "prodname": "$prodname"
       },
      "result_variable": "context.dataToSend"
     }
  ]
 }

So "prodname" is captured by Watson Assistant in the previous node (I checked that and it is working correctly) and sent to the Webhook. 因此,“prodname”由前一节点中的Watson Assistant捕获(我检查了它并且它正常工作)并发送到Webhook。 The variable used in the Webhook is also called "prodname". Webhook中使用的变量也称为“prodname”。 The expected output from the Webhook is stored in the variable "dataToSend", but as said above the answer in Watson is only "" as "$dataToSend" is "". Webhook的预期输出存储在变量“dataToSend”中,但如上所述,Watson中的答案仅为“”,因为“$ dataToSend”为“”。

I tried also with "result_variable": "dataToSend" and "result_variable": "$dataToSend" without success, so what I guess is that the webhook is not being called... 我也试过“result_variable”:“dataToSend”和“result_variable”:“$ dataToSend”没有成功,所以我猜是webhook没有被调用...

I am new in the topic, so please do not hesitate to correct any problems in my post. 我是这个主题的新手,所以请不要犹豫,纠正我的帖子中的任何问题。

Thanks in any case in advance! 无论如何,提前谢谢!

Adrià 阿德里亚

IBM Watson Assistant lists three different options of making a programmatic call from within a dialog node: IBM Watson Assistant列出了从对话节点中进行编程调用的三种不同选项

  1. client : your app is in charge of calling out to the action 客户 :您的应用负责呼吁采取行动
  2. server or cloud_function : IBM Cloud Functions action is invoked from Watson Assistant servercloud_function :从Watson Assistant调用IBM Cloud Functions操作
  3. web_action : The web action of an IBM Cloud Functions action is invoked from Watson Assistant web_action :从Watson Assistant调用IBM Cloud Functions操作的Web操作

If you host your webhook on IBM Cloud Functions, then Watson Assistant can directly call it. 如果您在IBM Cloud Functions上托管您的webhook,那么Watson Assistant可以直接调用它。 With your current hosting and client specified, your app is in charge. 在您指定当前托管和客户端的情况下 ,您的应用程序将负责。 In that case your app needs to check that the context includes the information about a client action, extract that related metadata, invoke the webhook and send the data back to Watson Assistant. 在这种情况下,您的应用需要检查上下文是否包含有关客户端操作的信息,提取相关元数据,调用webhook并将数据发送回Watson Assistant。

I have written an example for such a client action for my Watson conversation tool . 我为我的Watson会话工具编写了一个这样的客户端操作示例。 See that repo for instructions. 请参阅该回购说明。

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

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