gpt4 book ai didi

javascript - 亚马逊 Alexa 错误

转载 作者:行者123 更新时间:2023-11-30 14:56:08 26 4
gpt4 key购买 nike

我正在尝试构建 Alexa 技能。当有意向请求时,我仍在尝试让 Alexa 说些什么,但我收到错误消息,我不确定如何处理它。当我通过 Alexa 服务模拟器运行 Sample Utterance 时,出现错误:

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

如果我通过 lambda 测试事件运行相同的话语,我得到的错误是:

"errorMessage": "Exception: ReferenceError: output is not defined"

我的javascript代码是

exports.handler = (event, context) => {

try {
//New Session
if(event.session.new) {
console.log("NEW SESSION")
}

switch (event.request.type) {

//Launch Request
case "LaunchRequest":
console.log(`LAUNCH REQUEST`)
context.succeed(
generateResponse(
buildSpeechletResponse("Welcome to an Alexa Skill, this is running on a lambda function", true),
{}
)
)
break;

//Intent Request
case "IntentRequest":
console.log(`INTENT REQUEST`)

switch(event.request.intent.name) {
case "FindFlight":
//Get data from user to send to Fare Portal

//Clean up data to send back to user

context.succeed(
generateResponse(
buildSpeechletResponse("Flight Search", "You asked to find a flight", true),
{}
)
)
break;

default:
throw "Invalid intent"
}
break;

//Session Ended Request
case "SessionEndedRequest":
console.log(`SESSION ENDED REQUEST`)
break;

default:
context.fail(`INVALID REQUEST TYPE: ${event.request.type}`)
}
} catch(error) {context.fail(`Exception: ${error}`)}

//Helpers
buildSpeechletResponse = (title, outputText, shouldEndSession) => {

return {
outputSpeech: {
type: "PlainText",
text: outputText
},
card: {
type: 'Simple',
title: `SessionSpeechlet - ${title}`,
content: `SessionSpeechlet - ${output}`,
},
shoudlEndSession: shouldEndSession
}
}

generateResponse = (sessionAttributes, speechletResponse) => {

return {
version: "1.0",
sessionAttributes: sessionAttributes,
response: speechletResponse
}
}
}

如有任何帮助,我们将不胜感激!

最佳答案

这似乎是 buildSpeechletResponse 函数中的错字:

content: `SessionSpeechlet - ${outputText}`,

关于javascript - 亚马逊 Alexa 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47254391/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com