Alexa Skill ARN - 无法调用远程端点,或者它返回的响应无效 [英] Alexa Skill ARN - The remote endpoint could not be called, or the response it returned was invalid

查看:27
本文介绍了Alexa Skill ARN - 无法调用远程端点,或者它返回的响应无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的 Lambda 函数来调用网页,当我从函数页面测试它时,这很好用,但是在尝试创建调用此函数的技能时,我最终得到了远程端点无法调用,或者它返回的响应无效."错误.

I've created a simple Lambda function to call a webpage, this works fine when I test it from the functions page however when trying to create a skill to call this function I end up with a "The remote endpoint could not be called, or the response it returned was invalid." error.

Lambda 函数

var http = require('http');

exports.handler = function(event, context) {
  console.log('start request to ' + event.url)
  http.get(event.url, function(res) {
    console.log("Got response: " + res.statusCode);
    context.succeed();
  }).on('error', function(e) {
    console.log("Got error: " + e.message);
    context.done(null, 'FAILURE');
  });

  console.log('end request to ' + event.url);
}

测试事件代码如下所示:

The Test Event code looks like this:

{
  "url": "http://mywebsite.co.uk"
}

并且我为Alexa Skills Kit"添加了一个触发器.

and I've added a trigger for the "Alexa Skills Kit".

此函数的 ARN 显示为:

The ARN for this function is showing as:

arn:aws:lambda:us-east-1:052516835015:function:CustomFunction

arn:aws:lambda:us-east-1:052516835015:function:CustomFunction

Alexa Skill(开发者门户)

然后我创建了一个具有简单意图的技能:

I've then created a skill with a simple Intent:

{
 "intents": [
   {
 "intent": "CustomFunction"
   }
 ]
}

并创建了一个话语:

CustomFunction execute my custom function

在我的技能的配置部分中,我选择了AWS Lambda ARN(亚马逊资源名称)"选项并将 ARN 输入到北美的框中.

In the Configuration section for my skill I have selected the "AWS Lambda ARN (Amazon Resource Name)" option and entered the ARN into the box for North America.

在测试 -> 服务模拟器部分,我添加了执行我的自定义函数"作为文本,这会更改 Lambda 请求以显示:

In the Test -> Service Simulator section, I've added "execute my custom function" as the Text and this changes the Lambda Request to show:

{
  "session": {
"sessionId": "SessionId.a3e8aee0-acae-4de5-85df-XXXXXXXXX",
"application": {
  "applicationId": "amzn1.ask.skill.XXXXXXXXX"
},
"attributes": {},
"user": {
  "userId": "amzn1.ask.account.XXXXXXXXX"
},
"new": true
  },
  "request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.445267bd-2b4a-45ef-8566-XXXXXXXXX",
"locale": "en-GB",
"timestamp": "2016-11-27T22:54:07Z",
"intent": {
  "name": "RunWOL",
  "slots": {}
}
  },
  "version": "1.0"
}

但是当我运行测试时出现以下错误:

but when I run the test I get the following error:

无法调用远程端点,或者它返回的响应无效.

The remote endpoint could not be called, or the response it returned was invalid.

有没有人对为什么技能无法连接到函数有任何想法?

Does anyone have any ideas on why the skill can't connect to the function?

谢谢

推荐答案

Amazon Alexa 开发人员控制台中内置的服务模拟器存在已知问题.尝试复制模拟器生成的 JSON 并将其粘贴到 lambda 函数的测试事件中.要访问 lambda 的测试事件,首先找到蓝色的测试"按钮.在该按钮旁边选择(操作下拉菜单)->(配置测试事件)-> 将提供的 JSON 粘贴到代码区域->(保存和测试).Lambda 的内置测试功能比 Alexa 的可靠得多.

The Service Simulator built into the Amazon Alexa Developer Console has known issues. Try copying the JSON generated by the Simulator and pasting it into your lambda function's test event. To access lambda's test events first find the blue 'Test' button. Next to that button select the (Actions Drop down menu) -> (Configure Test Event) -> Paste the provided JSON into the code area -> (Save and Test). Lambda's built in testing features are much more reliable than Alexa's.

如果这不能解决问题,lambda 的测试事件将返回完整的堆栈跟踪和错误代码.当每个错误都不是无法调用远程端点,或者它返回的响应无效"时,故障排除变得容易得多.

If this does not solve the problem lambda's testing event returns a complete stackTrace and error codes. It becomes much easier to trouble shoot when every error isn't "The remote endpoint could not be called, or the response it returned was invalid."

{
  "session": {
"sessionId": "SessionId.a3e8aee0-acae-4de5-85df-XXXXXXXXX",
"application": {
  "applicationId": "amzn1.ask.skill.XXXXXXXXX"
},
"attributes": {},
"user": {
  "userId": "amzn1.ask.account.XXXXXXXXX"
},
"new": true
  },
  "request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.445267bd-2b4a-45ef-8566-XXXXXXXXX",
"locale": "en-GB",
"timestamp": "2016-11-27T22:54:07Z",
"intent": {
  "name": "RunWOL",
  "slots": {}
}
  },
  "version": "1.0"
}

这篇关于Alexa Skill ARN - 无法调用远程端点,或者它返回的响应无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆