如果使用者取消連結 smart home 動作與 Google Assistant,執行要求會收到 action.devices.DISCONNECT 意圖。這項意圖表示 Assistant 不會再為這位使用者傳送任何意圖,您的雲端服務應停止為其裝置呼叫 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意圖參考說明文件。