我正在开发回声表演的技能。但是我无法显示来自 python lambda 技能的所有显示模板和内容。我能够完美地完成 alexa 技能,并且能够添加效果很好的图片 url。但是添加显示模板时,显示无效响应。
这是要添加到 json 响应中的额外参数。
directives: [
{
type: “Display.RenderTemplate”,
template: {
type: “BodyTemplate1”,
token: “T123”,
backButton: “HIDDEN”,
backgroundImage: {
contentDescription: “StormPhoto”,
sources: [
{
url: “https://s3.amazonaws.com/hurricane-data/hurricaneBackground.png”
}
]
},
title: “Hurricane Center”,
textContent: {
primaryText: {
text: output,
type: “PlainText”
}
}
}
}],
这就是我修改后的渲染模板方法的样子。def build_speechlet_response(title, output, reprompt_text, should_end_session): imgurl="https://thesweetsetup.com/wp-content/uploads/2014/10/scanbot_ico_1024.png"
return {
'outputSpeech': {
'type': 'PlainText',
'text': output
},
'card': {
'type': 'Standard',
'title': title,
'text': output,
"image": {
"smallImageUrl": imgurl,
"largeImageUrl": imgurl
}
},
'reprompt': {
'outputSpeech': {
'type': 'PlainText',
'text': reprompt_text
}
},
directives: [
{
type: “Display.RenderTemplate”,
template: {
type: “BodyTemplate1”,
token: “T123”,
backButton: “HIDDEN”,
backgroundImage: {
contentDescription: “StormPhoto”,
sources: [
{
url: “https://s3.amazonaws.com/hurricane-data/hurricaneBackground.png”
}
]
},
title: “Hurricane Center”,
textContent: {
primaryText: {
text: output,
type: “PlainText”
}
}
}
}],
'shouldEndSession': should_end_session
}
但这给了我错误的响应格式。我在这里做错了什么。