Google Assistant SDK中的多个命令 [英] Multiple commands in Google Assistant SDK

查看:77
本文介绍了Google Assistant SDK中的多个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划使用Google Assistant SDK实施2个自定义命令,并且已经对actions.json文件(如下所示)进行了适当的更改.但是,以某种方式一次仅触发一个命令,即随机启动或选择命令.如何使其触发两个命令?

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

}

推荐答案

您应该合并两个actions数组.该文件是一组键值,因此重复的键意味着该值将替换前一个:

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

这篇关于Google Assistant SDK中的多个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆