从 Watson Assistant 调用 OpenWeather API:"Direct CloudFunctions call was not successful"

Calling OpenWeather API from Watson Assistant: "Direct CloudFunctions call was not successful"

我正在尝试将 openweathermap API 与 Watson Assistant 一起使用,但我收到“Webhook 调用不成功。响应代码为 [404]”。(日志中还有 1 个错误) ."

(我根据 Sabharwal 等人的书创作,对过时的元素进行了自己的即兴创作,例如@sys-location。)

我创建了一个名为“https://us-south.functions.appdomain.cloud/api/v1/web/my-account-email%40dev/default/Weather-Connection”的 Cloud Functions Action,并选中了 Enable as Web Action。操作代码是从 git 书库导入的:

let rp = require('request-promise')
function main(params) {
    const options = {
        uri: "http://api.openweathermap.org/data/2.5/weather?q=" + encodeURIComponent(params.object_of_interest)+ "&units=metric&APPID=19e8588cb3d7d0623e3a5a8ec529232f" ,
        json: true
    }
    return rp(options)
    .then(res => {
        WeatherReport = "Current Temperature : " +res.main.temp+ ", Pressure : " + res.main.pressure + ", Humidity : " + res.main.humidity + ", temp min : " + res.main.temp_min + " , temp max : " + res.main.temp_max
        return { WeatherReport
        } 
    })
}

在“助手选项”中,webhook URI 设置为 https://us-south.functions.appdomain.cloud/api/v1/web/my-account-email%40dev/default/Weather-Connection.json.

“Google 助理回复”JSON 是 “助理回复”JSON 是

{
  "output": {
    "text": {
      "values": [],
      "selection_policy": "sequential"
    }
  },
  "actions": [
    {
      "name": "/my-account-email%40dev/default/Weather-Connection.json",
      "type": "cloud_function",
      "parameters": {
        "object_of_interest": "$location"
      },
      "credentials": "$credentials",
      "result_variable": "$response"
    }
  ],
  "context": {
    "credentials": {
      "api_key": "[my-openweathermap-api-key]"
    },
    "object_of_interest": "@object_of_interest"
  }
}

为了调试,我包含了一个显示 $location 值的对话节点,没问题(例如“伦敦”)。

“试用”窗格显示 {“cloud_functions_call_error”:“请求的资源不存在。”} 当我单击“错误”图标时,出现运行时错误弹出窗口,显示 Direct CloudFunctions call was not successful. Http response code is [404]. (and there is 1 more error in the log).

我没有从 运行 CLI 命令 ibmcloud fn activation list 得到任何输出(我不确定这是检查日志的正确方法)。

我已经通过使用参数 {"object_of_interest": "London"} 调用 Action 测试了 Weather-Connection 功能,并且它有效。

所有内容都部署在同一区域 (us-south) 和命名空间中。

我想不出还有什么可以尝试的。

我刚刚破解了它。我试图使用文本 response is <? $webhook_result_1.response ?> 显示结果,而它本应是 response is <? $webhook_result_1 ?>.