Multiple commands in Google Assistant SDK

可紊 提交于 2020-01-16 19:43:08

问题


I am planning to implement 2 custom commands using the Google Assistant SDK and I have made appropriate changes in the actions.json file (Attached Below). However, somehow only one of the command gets triggered at a time i.e. either the start or select commands randomly. How do I make it trigger both commands?

{
 "manifest": {
    "displayName": "Start Test",
    "invocationName": "Start Test",
    "category": "PRODUCTIVITY"
},
"actions": [
    {
        "name": "com.example.actions.StartTest",
        "availability": {
            "deviceClasses": [
                {
                    "assistantSdkDevice": {}
                }
            ]
        },
        "intent": {
            "name": "com.example.intents.StartTest",
            "parameters": [
                {
                    "name": "testname",
                    "type" : "SchemaOrg_Number"
                }
            ],
            "trigger": {
                "queryPatterns": [
                    "prepare test ($SchemaOrg_Number:testname)"
                ]
            }
        },
        "fulfillment": {
            "staticFulfillment": {
                "templatedResponse": {
                    "items": [
                        {
                            "simpleResponse": {
                                "textToSpeech": "Preparing to start test $testname"
                            }
                        },
                        {
                            "deviceExecution": {
                                "command": "com.example.commands.StartTest",
                                "params": {
                                    "testname": "$testname"
                                }
                            }
                        }
                    ]
                }
            }
        }
    }
],
"types": [
    {
        "name": "$testname",
        "entities": [
            {
                "key": "5",
                "synonyms": [
                    "Test5"
                ]
            }
        ]
    }
],

"manifest": {
    "displayName": "Select Lane",
    "invocationName": "Select Lane",
    "category": "PRODUCTIVITY"
},
"actions": [
    {
        "name": "com.example.actions.SelectLane",
        "availability": {
            "deviceClasses": [
                {
                    "assistantSdkDevice": {}
                }
            ]
        },
        "intent": {
            "name": "com.example.intents.SelectLane",
            "parameters": [
                {
                    "name": "lanename",
                    "type" : "SchemaOrg_Number"
                }
            ],
            "trigger": {
                "queryPatterns": [
                    "select lane ($SchemaOrg_Number:lanename)"
                ]
            }
        },
        "fulfillment": {
            "staticFulfillment": {
                "templatedResponse": {
                    "items": [
                        {
                            "simpleResponse": {
                                "textToSpeech": "Selected lane $lanename"
                            }
                        },
                        {
                            "deviceExecution": {
                                "command": "com.example.commands.SelectLane",
                                "params": {
                                    "lanename": "$lanename"
                                }
                            }
                        }
                    ]
                }
            }
        }
    }
],
"types": [
    {
        "name": "$lanename",
        "entities": [
            {
                "key": "5",
                "synonyms": [
                    "Lane5"
                ]
            }
        ]
    }
]

}


回答1:


You should consolidate your two actions arrays. The file is meant to be a set of key-values, so repeated keys mean the value will replace the previous one:

"actions": [
  {
     "name": "com.example.action",
     // ...
  },
  {
     "name": "com.example.bction",
     // ...
  }
]

You should do the same for types:

"types": [
  {
    "name": "$type",
    // ...
  },
  {
    "name": "$bype"
  }
]


来源:https://stackoverflow.com/questions/50350924/multiple-commands-in-google-assistant-sdk

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