Reputation: 346
I am trying to use the openweathermap API with Watson Assistant, but I am getting "Webhook call was not successful. Response code is [404]. (and there is 1 more error in the log)."
(I am working from the book by Sabharwal, et al., with my own improvisations for the obsolete elements, like @sys-location.)
I created a Cloud Functions Action called "https://us-south.functions.appdomain.cloud/api/v1/web/my-account-email%40dev/default/Weather-Connection" and checked Enable as Web Action. The action code was imported from the git repo for the book:
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
}
})
}
In the Assistant Options the webhook URI is set to
https://us-south.functions.appdomain.cloud/api/v1/web/my-account-email%40dev/default/Weather-Connection.json
.
The "Assistant responds" JSON is The "Assistant responds" JSON is
{
"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"
}
}
For debugging, I included a dialog node that displays the value of $location, and it is okay (e.g. "London").
The "Try it out" pane prints {"cloud_functions_call_error":"The requested resource does not exist."} When I click on the Error icon I get a Runtime error pop-up saying, Direct CloudFunctions call was not successful. Http response code is [404]. (and there is 1 more error in the log)
.
I am not getting any output from running the CLI command ibmcloud fn activation list
(I'm not sure that's the right way to check the logs).
I have tested the Weather-Connection function by invoking the Action with parameter {"object_of_interest": "London"}
, and it works.
Everything is deployed in the same region (us-south) and namespace.
I can't think of anything else to try.
Upvotes: 0
Views: 238
Reputation: 346
I just cracked it. I was trying to show the result using the text response is <? $webhook_result_1.response ?>
when it should just have been response is <? $webhook_result_1 ?>
.
Upvotes: 0