gpt4 book ai didi

actions-on-google - askWith 谷歌上的操作列表

转载 作者:行者123 更新时间:2023-12-01 12:19:47 26 4
gpt4 key购买 nike

我在以下链接中关注 Action on 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"
},
}

}

任何帮助将不胜感激!提前谢谢你。

最佳答案

您正在使用 Actions 版本 2 功能,但 actions.json 包未指定版本,因此它默认为版本 1。

actions.json 的“对话”部分应该类似于:

"conversations": {
"welcome": {
"name": "welcome",
"url": "https://example.com",
"fulfillmentApiVersion": 2
},
}

关于actions-on-google - askWith 谷歌上的操作列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45311755/

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