對話動作已於 2023 年 6 月 13 日淘汰。詳情請參閱「
對話動作已淘汰」。
裝置動作總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
透過 Google 助理 SDK,您可以將 Google 助理嵌入自己的專案,讓專案的功能與 Google Home 類似。不過,您的專案可能具備 Google Home 沒有的獨特硬體功能,例如可自訂亮度與色彩設定的獨特 LED 螢幕。
裝置動作是一組工具和 API,可讓您在開發的專案中擴充 Google 助理的功能,充分發揮硬體效能。
內建裝置動作
Google 為日常用品 (包括燈具、家電和攝影機) 建立各種常見的內建裝置動作。透過這些動作,您可以運用 Google 助理的自然語言處理功能來控制專案。舉例來說,開啟燈具專案的方式如下:
- Ok Google,幫我開燈。
- 「Ok Google,幫我開燈。」
- Ok Google,打開客廳的燈。
您可以建立自己的專案,回應許多智慧住宅特徵
的指令,例如:
- Ok Google,將亮度設為 50%。
- Ok Google,將溫度設為 37 度。
自訂裝置動作
您也可以為自己的專屬硬體建立自訂裝置動作。針對這些動作,您需要定義文法和指令:
- Ok Google,讓燈閃爍 5 次。
- Ok Google,向左移動。
進一步瞭解如何使用 Google 助理服務整合這些動作。
運作方式
裝置已安裝 Google 助理 SDK,以及存取 Google 助理服務的憑證。裝置會傳送語音要求 (「開啟」),並要求服務開啟裝置內建的 LED。裝置也會傳送模型和裝置例項 ID,讓服務判斷如何根據要求內容提供最佳回應。
這項服務會使用自動語音辨識 (ASR) 技術判斷使用者說了哪些字詞,並運用自然語言處理 (NLP) 技術分析及瞭解這些字詞的意義,然後透過裝置比對功能提供要求背景資訊。這個內容非常重要,因為它會定義裝置支援的動作,以及這些動作的完成方式。
接著,服務會傳回文字,並以語音回覆使用者 (「好的」),
同時傳回裝置專屬指令。裝置知道如何處理這項指令:開啟 LED!

開始使用
將 Google 助理嵌入專案,然後使用裝置動作新增獨特功能,讓想法得以具體呈現。您可以使用 Google 助理服務開發專案。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eThe Google Assistant SDK enables you to integrate the Google Assistant into your projects, similar to a Google Home, and leverage Device Actions to utilize unique hardware features.\u003c/p\u003e\n"],["\u003cp\u003eDevice Actions provide tools and APIs to extend the Assistant's capabilities, allowing your project to respond to voice commands for functionalities like lights, appliances, and cameras using built-in or custom actions.\u003c/p\u003e\n"],["\u003cp\u003eBuilt-in Device Actions cover common smart home features, while Custom Device Actions let you define unique voice commands and functionalities tailored to your specific hardware.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Assistant service utilizes Automatic Speech Recognition, Natural Language Processing, and device context to understand user requests and trigger corresponding actions on your device.\u003c/p\u003e\n"],["\u003cp\u003eYou can get started by embedding the Google Assistant into your project and adding custom functionalities with Device Actions using the provided resources and guides.\u003c/p\u003e\n"]]],[],null,["# Device Actions Overview\n\nWith the Google Assistant SDK, you can embed the Google Assistant into your\nown project, making it function similarly to a Google Home. However, your project\nmay have unique hardware capabilities that Google Home does not have: for\nexample, it may have a unique LED display with customizable brightness and\ncolor settings.\n\nDevice Actions are a set of tools and APIs that allow you to extend what\nthe Assistant can do, in the projects you develop, to take full potential of\ntheir hardware capabilities.\n\nBuilt-in Device Actions\n-----------------------\n\nGoogle has created a wide range of common built-in device actions for everyday\nthings, including lights, appliances, and cameras. With these actions, you can\nharness the power of the Google Assistant's natural language processing to\ncontrol your project. For example, a project with a light can be turned on in\ndifferent ways:\n\n- *Ok Google, turn on the light.*\n- *Hey Google, turn my light on.*\n- *Ok Google, turn on my living room light.*\n\nYou can create your own project that responds to commands for\nmany\n[smart home traits](/assistant/sdk/reference/traits)\nlike:\n\n- *Ok Google, set the brightness to 50%.*\n- *Hey Google, set the temperature to 98 degrees.*\n\nCustom Device Actions\n---------------------\n\nYou can also create custom device actions for your own unique hardware. For these\nactions, you define the grammar and commands:\n\n- *Ok Google, blink my light 5 times.*\n- *Hey Google, move left.*\n\nLearn more about incorporating these actions using the [Google Assistant service](/assistant/sdk/guides/service/python/extend/custom-actions).\n\nHow it works\n------------\n\nThe device has the Google Assistant SDK installed on it along with credentials for\naccessing the Google Assistant Service. The device sends out the spoken request\n(*Turn on.*) and asks the service to turn on the device's onboard LED.\nThe device also sends its model and device instance identifiers so the service\ncan determine how to best respond in context to the request.\n\nThe service uses Automatic Speech Recognition (ASR) to determine what words were\nspoken by the user, Natural Language Processing (NLP) to analyze and understand\nthe meaning of the request from these words, and device matching to provide context\nfor the request. This context is important because it defines the actions the\ndevice supports and how these actions should be fulfilled.\n\nThe service then responds with text that is spoken back to the user (*Sure.*)\nalong with the device-specific command. The device knows how to handle this\ncommand: it turns on its LED!\n\nGet started\n-----------\n\nBring your ideas to life by embedding the Google Assistant\ninto your project and then adding unique functionality with Device\nActions. You can develop your project [using the Google Assistant service](/assistant/sdk/guides/service/python)."]]