Google 上的 askWith 操作列表

askWithList on Actions on Google

我在以下 link:

上遵循 Google 响应的示例代码

https://developers.google.com/actions/assistant/responses

我希望列表响应在用户启动文本意图时出现,但我得到的只是 "Your App isn’t responding right now. Try again soon." 这是我正在使用的代码(大部分是从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:

{
    "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" 部分应该类似于:

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