0
votes

I created a very simple cloud function in IBM, that I try to call via Watson assistant. When I call it the error "Direct CloudFunctions call was not successful. Http response code is [401]" appears.

Underneath is the code I am using. "prodname" is taken from the user and sent to the function to get an answer. The function is working fine when I invoke it. I get the ID and password from https://cloud.ibm.com/openwhisk/learn/api-key.

{
  "context": {

    "credentials": {
      "user": "userID",
      "password": "password"
    }
  },
  "output": {
    "text": {
      "values": [
        "$answer"
      ]
    }
  },
  "actions": [
    {
      "name": "arllambi%2540gmail.com_Only/Watson/MovieBot",
      "type": "cloud_function",
      "parameters": {
        "prodname": "$prodname"
      },
      "result_variable": "answer",
      "credentials": "$credentials"
    }
  ]
}

Is it possible that there is some problem with the credentials?

Thanks in advance for any help.

****** reEDIT ******

As suggested by data_henrik I provide futher info. The function I am calling is the following, a very simple echo function:

function main(msg){
return {answer: "You said " +msg.prodname};
}

I changed the cloud_function to web_action, web_action works fine via postman:

{
  "output": {
    "text": {
      "values": [
        "$answer"
      ]
    }
  },
  "actions": [
    {
      "name": "[email protected]_Only/Watson/MovieBot.json",
      "type": "web_action",
      "parameters": {
        "prodname": "<?input.text?>"
      },
      "result_variable": "context.answer"
    }
  ]
}

The message I get now is "Direct CloudFunctions call was not successful. Http response code is [404]". Also the assistant answers "with {"cloud_functions_call_error":"The requested resource does not exist."}

Adrià

2
Are you using the api_key or user/password? Check the Cloud Functions log for details.data_henrik
hi and thanks for the quick answer(s)! I am using the user/password data coming from the cloud.ibm.com/openwhisk/learn/api-key. The clound function logs do not show anything: Activation ID: 702e4121f77347d2ae4121f77387d27d Results: { "answer": "You said terminator" } Logs: []Triferus
Share more details about what code you are calling and the action name. Why don't you use the api_key instead of user/password?data_henrik
For the sake of exercise, could you enable the action as web action and then call it that way?data_henrik
Thanks for the feedback, above is updated.Triferus

2 Answers

1
votes

Hi @data_henrik and thanks for the help. I did see the @ and corrected it in the edited code, was giving the same problem. BUT I figured it out: the assistant was deployed in Washington... I moved it to London and now it works. Thanks again for the help and sorry for my newbie mistake...

0
votes

My guess is that the org part in your action name is wrong. Try to replace any "@" with "%40". Else, it will be interpreted by Watson as something else. Next, after you update the dialog node, wait for some seconds for the changes to take effect.

I just tried something with my deployed web actions and could cause the 401 and 404.

"name": "arllambi%40gmail.com_Only/Watson/MovieBot.json"