簡體   English   中英

Google Assistant SDK中的多個命令

[英]Multiple commands in Google Assistant SDK

我計划使用Google Assistant SDK實施2個自定義命令,並且對actions.json文件(如下所示)進行了適當的更改。 但是,一次只能一次觸發一個命令,即隨機啟動或選擇命令。 如何使其觸發兩個命令?

{
 "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"
                ]
            }
        ]
    }
]

}

您應該合並兩個actions數組。 該文件是一組鍵值,因此重復的鍵意味着該值將替換前一個:

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

您應該對類型執行相同的操作:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM