ARB*_*ARB 6 javascript http alexa node.js aws-lambda
我试图让Alexa技能(JS/Lambda)使用HTTP.request将值发布到REST服务器.我试图破解一些简单的东西来完成工作.我想我错过了一些明显的东西.
我有两个问题:
口语与打字的话语.如果我在亚马逊服务模拟器("五")中键入我的插槽值,则该值将发布到我的服务器,应该是这样.但是,如果我说同样的话,即使Alexa正确地识别了这些词(通过在应用程序中查看卡片确认),该值也没有发布,她说,"我找不到问题的答案."
在哪里以及如何调用输出函数.我想我需要添加类似下面两行的内容,但是根据我在当前代码中添加它的位置,Alexa要么在不更新节点的情况下做出响应,要么不做任何事情.
var text = 'I have updated the value to' + targetSlot;
output( text, context );
Run Code Online (Sandbox Code Playgroud)posting test
Run Code Online (Sandbox Code Playgroud)
{
"intents": [ {
"intent": "writeTarget",
"slots": [ {
"name": "Target",
"type": "NUMBER"
} ]
}]
}
Run Code Online (Sandbox Code Playgroud)
writeTarget {Target}
Run Code Online (Sandbox Code Playgroud)
我正在使用AlexaSkill.js文件,可在此处的每个示例中找到.
我的index.js看起来像这样.URL,req.write字符串等替换为****.
exports.handler = function( event, context ) {
var APP_ID = undefined;
const http = require( 'http' );
var AlexaSkill = require('./AlexaSkill');
var options = {
host: '****.com',
path: '/****',
port: '****',
method: 'PUT'
};
callback = function(response) {
var str = ''
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
console.log(str);
});
};
var targetSlot = event.request.intent.slots.Target.value;
var req = http.request(options, callback);
req.write("****");
req.end();
};
function output( text, context ) {
var answer = {
outputSpeech: {
type: "PlainText",
text: text
},
card: {
type: "Simple",
title: "System Data",
content: text
},
shouldEndSession: true
};
context.succeed( { answer: answer } );
}
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助.
更新帖子以添加日志:
{
"errorMessage": "Process exited before completing request"
}
Run Code Online (Sandbox Code Playgroud)
TypeError: Cannot read property 'intent' of undefined
at exports.handler (/var/task/index.js:24:35)
Run Code Online (Sandbox Code Playgroud)
The response is invalid
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6098 次 |
| 最近记录: |