Google Assistant SDK多参数命令无法被检测问题排查求助
解决Google Assistant SDK双参数查询模式未被检测的问题
我仔细看了你提供的Actions JSON配置,发现了几个关键问题,正是这些问题导致双参数的查询模式无法被正确识别:
1. 自定义类型名称不匹配
这是最核心的问题:你在types数组里定义的类型名称是$TestSchema和$MachineSchema(带$前缀),但在intent的parameters和queryPatterns中引用的却是TestSchema和MachineSchema(不带$)。Google Assistant对类型名称的匹配是严格大小写和字符完全一致的,这种不匹配会导致系统无法关联你定义的自定义实体,自然解析不了双参数的查询。
修正方案
把types里的类型名称去掉$前缀,和你在参数中使用的名称保持一致:
"types": [ { "name": "TestSchema", // 移除$前缀 "entities": [ { "key": "BURN IN", "synonyms": [ "burnin", "burn in", "burning", "button" ] }, { "key": "WINTHRAX", "synonyms": [ "when thanks", "print tracks", "fintrax", "win tracks", "winter sucks" ] }, { "key": "REBOOTER", "synonyms": [ "reporter", "repeat here", "reboot" ] }, { "key": "SLEEPER", "synonyms": [ "sleeper", "sleep here", "slipper" ] }, { "key": "IOMONKEY", "synonyms": [ "are you monkey", "I O monkey", "I am monkey" ] }, { "key": "DISKERCISE", "synonyms": [ "discus size", "discuss I", "Tisca size", "Kiska size", "discuss Eyes" ] }, { "key": "MFCJUNI", "synonyms": [ "M F C Juni", "MFC tunie", "MFC tune", "MFC Tu Ne" ] }, { "key": "SD STRESS", "synonyms": [ "S D Stress", "H D Stress", "SD stress", "HD stress", "is distress", "s distress", "sdstress", "SPSS", "has De stress", "FB status", "HD stores", "St stress" ] }, { "key": "POUNDIT", "synonyms": [ "pound it", "pundit", "found it", "foundit", "pound rate", "founded" ] } ] }, { "name": "MachineSchema", // 移除$前缀 "entities":[ { "key": "HP LANE", "synonyms": [ "HP lane", "hp lane", "hp line", "h plane", "hplane", "hp name", "HP rain", "hp rain", "HP name" ] }, { "key": "TPC-1001", "synonyms": [ "tpc1001", "tpc one thousand one", "tpc 1001", "tpc one thousand 1" ] }, { "key": "TPC-1002", "synonyms": [ "tpc1002", "tpc one thousand two", "tpc 1002", "tpc one thousand 2" ] }, { "key": "TPC-1003", "synonyms": [ "tpc1003", "tpc one thousand three", "tpc 1003", "tpc one thousand 3" ] } ] } ]
同时,确保intent的parameters里的type字段和修正后的类型名称完全匹配(你当前的写法已经是TestSchema和MachineSchema,这部分不需要修改):
"parameters": [ { "name": "testname", "type" : "TestSchema" // 已匹配修正后的类型名称 }, { "name": "machinename", "type" : "MachineSchema" // 已匹配修正后的类型名称 } ]
你的queryPatterns写法本身是正确的,修正类型名称后,这些模式就能正常关联到对应的实体了:
"queryPatterns": [ "prepare ($TestSchema:testname) on ($MachineSchema:machinename)", "start ($TestSchema:testname) on ($MachineSchema:machinename)", "launch ($TestSchema:testname) on ($MachineSchema:machinename)" ]
2. 额外测试建议
- 先使用实体的精准
key进行测试,比如直接说**"prepare BURN IN on HP LANE"**,确认双参数能被正确识别后,再测试同义词的效果,避免同义词干扰问题排查。 - 检查JSON文件是否有语法错误,比如遗漏逗号、引号不匹配等,这类问题也可能导致配置无法被正确加载。
内容的提问来源于stack exchange,提问作者unholy_me
相关产品推荐
相关产品推荐

