askWithList on Actions on Google

ε祈祈猫儿з 提交于 2019-12-14 01:15:01

问题


I'm following the sample code for Action on Google responses at the following link:

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

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);

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.


回答1:


You're using Actions version 2 features, but the actions.json package isn't specifying a version, so it defaults to version 1.

The "conversations" section of actions.json should look something like:

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


来源:https://stackoverflow.com/questions/45311755/askwithlist-on-actions-on-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!