如果用户解除您的 smart home 操作与 Google Assistant 的关联,您的执行方式会收到 action.devices.DISCONNECT
intent。此 intent 表示 Assistant 将不会再为此用户发送 intent,您的云服务应停止为其设备调用 Google Home Graph API(请求同步和 Report State)。
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.DISCONNECT", }] }
JSON
{}
Node.js
const {smarthome} = require('actions-on-google'); const app = smarthome(); // ... app.onDisconnect((body, headers) => { // TODO Disconnect user account from Google Assistant // You can return an empty body return {}; });
Java
@Override public void onDisconnect( @NotNull DisconnectRequest disconnectRequest, @Nullable Map<?, ?> map) { // TODO Disconnect user account from Google Assistant // This function does not return anything }
如需了解详情,请参阅 DISCONNECT
intent 参考文档。