askWithCarousel()返回空响应

时间:2017-11-08 12:48:00

标签: actions-on-google google-assistant-sdk api-ai dialogflow

这是我正在使用的代码片段:

app.askWithCarousel('Which of these looks good?',
    app.buildCarousel()
        .addItems([
            app.buildOptionItem("SELECTION_KEY_ONE",
                ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'])
                .setTitle('Number one'),
            app.buildOptionItem("SELECTION_KEY_TWO",
                ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'])
                .setTitle('Number two'),
        ]));

这是截图:

enter image description here enter image description here

1 个答案:

答案 0 :(得分:1)

我找到了解决方案。这可能是谷歌的一个bug。您所要做的就是添加.setDescription方法

app.askWithCarousel('Which of these looks good?',
    app.buildCarousel()
        .addItems(
            app.buildOptionItem("SELECTION_KEY_ONE",
                            ['synonym of KEY_ONE 1', 'synonym of KEY_ONE 2'])
                            .setTitle('Number one')
                            .setDescription('Number one description')
            )
        .addItems(
            app.buildOptionItem("SELECTION_KEY_TWO",
                            ['synonym of KEY_TWO 1', 'synonym of KEY_TWO 2'])
                            .setTitle('Number two')
                            .setDescription('Number two description')
            )
);

<强>更新

我刚刚发现,不可能设置像.setDescription('')这样的空字符串。它返回一个错误。所以,我相处空间.setDescription(' ')