首页 文章

askWithList on Google上的动作

提问于
浏览
3

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

}

任何帮助将非常感激!先感谢您 .

1 回答

  • 4

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

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

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

相关问题