我尽一切努力使this示例工作正常(尤其是“轮播”部分)。每次我尝试使用Google上的操作中的“列表”或“建议”或“轮播”时,都会在Google模拟器中出现以下错误: error from actions on google simulator
这是来自我的heroku webhook的Intent代码(是示例中的复制粘贴)
function prova(agent){
let conv = agent.conv();
const imageUrl = 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png';
const imageUrl2 = 'https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw';
const linkUrl = 'https://assistant.google.com/';
conv.ask(new Carousel({
title: 'Google Assistant',
items: {
'WorksWithGoogleAssistantItemKey': {
title: 'Works With the Google Assistant',
description: 'If you see this logo, you know it will work with the Google Assistant.',
image: {
url: imageUrl,
accessibilityText: 'Works With the Google Assistant logo',
},
},
'GoogleHomeItemKey': {
title: 'Google Home',
description: 'Google Home is a powerful speaker and voice Assistant.',
image: {
url: imageUrl2,
accessibilityText: 'Google Home'
},
},
},
}));
agent.add(conv);
}
所以,这是我的依赖项:
有人已经解决了这个问题吗?我什么都没找到...
提前谢谢!
答案 0 :(得分:1)
在您的实现中,您错过了原始示例中的一行。轮播之前,您需要先拥有SimpleResponse
。因此,您需要使用诸如
conv.ask('Please choose an item:');
在conv.ask()
的{{1}}之前的行上。
答案 1 :(得分:0)
您可以尝试像这样直接为Carousel添加JSON负载:
function prova(agent){
const imageUrl = 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png';
const imageUrl2 = 'https://lh3.googleusercontent.com/Nu3a6F80WfixUqf_ec_vgXy_c0-0r4VLJRXjVFF_X_CIilEu8B9fT35qyTEj_PEsKw';
const linkUrl = 'https://assistant.google.com/';
agent.add(new Payload(agent.ACTIONS_ON_GOOGLE, {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Please choose an item:"
}
}
]
},
"systemIntent": {
"intent": "actions.intent.OPTION",
"data": {
"@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
"carouselSelect": {
"items": [
{
"optionInfo": {
"key": "WorksWithGoogleAssistantItemKey"
},
"description": "If you see this logo, you know it will work with the Google Assistant.",
"image": {
"url": imageUrl,
"accessibilityText": "Works With the Google Assistant logo"
},
"title": "Works With the Google Assistant"
},
{
"optionInfo": {
"key": "GoogleHomeItemKey"
},
"description": "Google Home is a powerful speaker and voice Assistant.",
"image": {
"url": imageUrl2,
"accessibilityText": "Google Home"
},
"title": "Google Home"
}
]
}
}
}
}));
}