断开连接

如果用户解除您的 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 参考文档。