Google Assistant Android自定义App Actions无法触发:空调控制适配问题
我们正尝试将已停用的Conversational Actions中的空调控制功能迁移至Android应用,采用Google Assistant与App Actions实现。我们提供比家庭集成默认模型更高级的空调控制,例如单房间温度控制。
已通过res/xml/shortcuts.xml配置如下动作:
<?xml version="1.0" encoding="utf-8"?> <shortcuts xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <capability android:name="custom.actions.intent.AIRCON_ON" app:queryPatterns="@array/AirconQueries"> <intent android:action="android.intent.action.VIEW" android:targetClass="com.developer.validActivity" android:targetPackage="com.developer"> <parameter android:name="on_off" android:key="on_off" android:mimeType="https://schema.org/Text" /> </intent> </capability> </shortcuts>
res/values/arrays.xml中的AirconQueries数组配置如下:
<string-array name="AirconQueries"> <item>Switch Aircon $on_off</item> <item>Switch my Aircon $on_off</item> <item>Switch the Aircon $on_off</item> <item>Turn my Aircon $on_off</item> <item>Turn Aircon $on_off</item> <item>Turn the Aircon $on_off</item> </string-array>
该配置在App Actions模拟器中可正常运行,但通过Google Assistant输入指定指令时,Assistant始终将指令转向智能温度计,即便账户无关联设备也不会触发应用自定义动作。我们原本以为在指令末尾添加with/in/on **APP_NAME**可触发自定义动作,若此逻辑不成立,是否有禁用短语的详尽列表?
更新1
我们还按照官方文档尝试了Open **APP_NAME** and Switch my Aircon on的调用方式,仍无法触发,但不再出现智能温度计提示。
更新2
我们位于澳大利亚,是否en-AU地区暂不支持该功能?文档未明确说明。
针对上述问题,可从以下维度排查优化:
- 地域支持验证
Google Assistant的App Actions功能在部分地区的支持可能存在延迟或限制。你可以:
- 确认设备的Assistant地区设置为澳大利亚,且系统语言与地区一致;
- 临时切换至en-US地区测试,若功能正常,则说明en-AU暂未适配该场景。
修正自定义意图命名格式
当前自定义意图custom.actions.intent.AIRCON_ON不符合官方规范,正确格式应为actions.intent.<自定义意图名>,需修改为actions.intent.AIRCON_ON,并同步更新所有引用位置。优化查询模式,强化应用关联
现有查询模式未明确绑定应用,易被默认家庭设备意图抢占。建议在模式中加入应用名称相关触发词(替换为你的应用实际名称):
<string-array name="AirconQueries"> <item>Switch Aircon $on_off using [APP_NAME]</item> <item>Turn my Aircon $on_off with [APP_NAME]</item> <item>Control room Aircon $on_off on [APP_NAME]</item> </string-array>
同时加入“room”这类专属功能关键词,与通用空调控制指令区分开。
- 提升参数识别精准度
将on_off参数的https://schema.org/Text类型替换为更精准的https://schema.org/Boolean,让Assistant更易识别开关指令:
<parameter android:name="on_off" android:key="on_off" android:mimeType="https://schema.org/Boolean" />
规范触发指令格式
尝试使用更明确的指令格式,例如:Hey Google, ask [APP_NAME] to turn the room aircon on,这种格式更易触发自定义应用动作,减少被默认意图拦截的概率。应用关联与测试同步
- 确保应用已通过Google Play内部测试渠道或正式发布,测试设备安装对应版本;
- 使用App Actions Test Tool重新关联应用,确保配置同步至Assistant;
- 清除Assistant缓存后重新测试。
- 禁用短语说明
Google官方未公开完整禁用短语列表,但如果指令与内置家庭控制意图高度重合,即便添加应用名称也可能被拦截。此时需通过独特触发词(如结合“单房间”“专属空调”等你的功能特性)来区分。
内容的提问来源于stack exchange,提问作者DrZaphod

