我正在通过以下链接关注针对Google回复的操作示例代码:
https://developers.google.com/actions/assistant/responses
我想在用户启动文本意图时显示列表响应,但我得到的是“你的应用程序现在没有响应。请尽快重试。”这是我正在使用的代码(它大部分来自链接的复制和粘贴):
function textIntent(app) {
app.askWithList(app.buildRichResponse()
.addSimpleResponse('Alright')
.addSuggestions(
['Basic Card', 'List', 'Carousel', 'Suggestions']),
// Build a list
app.buildList('Things to learn about')
// Add the first item to the list
.addItems(app.buildOptionItem('MATH_AND_PRIME',
['math', 'math and prime', 'prime numbers', 'prime'])
.setTitle('Math & prime numbers')
.setDescription('42 is an abundant number because the sum of its ' +
'proper divisors 54 is greater…')
)
// Add the second item to the list
.addItems(app.buildOptionItem('EGYPT',
['religion', 'egypt', 'ancient egyptian'])
.setTitle('Ancient Egyptian religion')
.setDescription('42 gods who ruled on the fate of the dead in the ' +
'afterworld. Throughout the under…')
)
// Add third item to the list
.addItems(app.buildOptionItem('RECIPES',
['recipes', 'recipe', '42 recipes'])
.setTitle('42 recipes with 42 ingredients')
.setDescription('Here\'s a beautifully simple recipe that\'s full ' +
'of flavor! All you need is some ginger and…')
)
);
}
let actionMap = new Map();
actionMap.set(app.StandardIntents.MAIN, mainIntent);
actionMap.set(app.StandardIntents.TEXT, textIntent);
app.handleRequest(actionMap);
这是我的action.json:
{
"actions": [
{
"description": "Default Welcome Intent",
"name": "MAIN",
"fulfillment": {
"conversationName": "welcome"
},
"intent": {
"name": "actions.intent.MAIN"
}
},
],
"conversations": {
"welcome": {
"name": "welcome",
"url": "https://example.com"
},
}
}
任何帮助将不胜感激!提前谢谢。
答案 0 :(得分:4)
您正在使用Actions版本2功能,但actions.json包未指定版本,因此默认为版本1.
actions.json的“对话”部分应该类似于:
ImageView