在Google上的Actions中的askWithList [英] askWithList on Actions on Google
问题描述
我在下面的链接中关注Google响应操作的示例代码:
I'm following the sample code for Action on Google responses at the following link:
https://developers.google.com/actions/assistant/respons
我想要列表响应在用户启动文本意图时出现,但我得到的只是您的应用目前没有响应。请稍后重试。这是我正在使用的代码(大部分是从链接复制并粘贴的):
I want the list response to appear when the user initiates the text intent, but all I get is "Your App isn’t responding right now. Try again soon." Here is the code that I'm using (it's copy and paste for the most part from the link):
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:
Here is my 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"
},
}
}
任何帮助将不胜感激!
Any help would be much appreciated! Thank you in advance.
推荐答案
您正在使用Actions版本2功能,但actions.json包未指定版本,因此默认为版本1。
You're using Actions version 2 features, but the actions.json package isn't specifying a version, so it defaults to version 1.
actions.json的对话部分应类似于:
The "conversations" section of actions.json should look something like:
"conversations": {
"welcome": {
"name": "welcome",
"url": "https://example.com",
"fulfillmentApiVersion": 2
},
}
这篇关于在Google上的Actions中的askWithList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!