Tổng quan về thao tác trên thiết bị
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Với Google Assistant SDK, bạn có thể nhúng Trợ lý Google vào dự án của riêng mình, giúp dự án hoạt động tương tự như Google Home. Tuy nhiên, dự án của bạn có thể có các chức năng phần cứng riêng biệt mà Google Home không có: ví dụ: dự án có thể có một màn hình LED riêng biệt với các chế độ cài đặt độ sáng và màu sắc có thể tuỳ chỉnh.
Thao tác trên thiết bị là một bộ công cụ và API cho phép bạn mở rộng phạm vi hoạt động của Trợ lý trong các dự án mà bạn phát triển, nhằm khai thác tối đa khả năng phần cứng của thiết bị.
Hành động trên thiết bị gắn liền
Google đã tạo ra nhiều thao tác phổ biến được tích hợp sẵn trên thiết bị cho các hoạt động hằng ngày, bao gồm cả đèn, thiết bị và camera. Với những hành động này, bạn có thể khai thác sức mạnh của tính năng xử lý ngôn ngữ tự nhiên của Trợ lý Google để kiểm soát dự án của mình. Ví dụ: bạn có thể bật một dự án có đèn theo nhiều cách:
- Ok Google, bật đèn.
- Ok Google, bật đèn.
- Ok Google, bật đèn phòng khách.
Bạn có thể tạo dự án của riêng mình để phản hồi các lệnh cho nhiềuđặc điểm nhà thông minh
như:
- Ok Google, đặt độ sáng ở mức 50%.
- Ok Google, đặt nhiệt độ ở mức 98 độ.
Thao tác tuỳ chỉnh trên thiết bị
Bạn cũng có thể tạo các thao tác tuỳ chỉnh trên thiết bị cho phần cứng riêng của mình. Đối với những thao tác này, bạn xác định ngữ pháp và lệnh:
- Ok Google, nhấp nháy đèn 5 lần.
- Ok Google, di chuyển sang trái.
Tìm hiểu thêm về cách kết hợp các thao tác này bằng dịch vụ Trợ lý Google.
Cách hoạt động
Thiết bị đã cài đặt Google Assistant SDK cùng với thông tin đăng nhập để truy cập vào Dịch vụ Trợ lý Google. Thiết bị sẽ gửi yêu cầu bằng giọng nói (Bật.) và yêu cầu dịch vụ bật đèn LED trên thiết bị.
Thiết bị cũng gửi giá trị nhận dạng mô hình và phiên bản thiết bị để dịch vụ có thể xác định cách phản hồi tốt nhất trong bối cảnh của yêu cầu.
Dịch vụ này sử dụng tính năng Nhận dạng giọng nói tự động (ASR) để xác định những từ mà người dùng đã nói, Xử lý ngôn ngữ tự nhiên (NLP) để phân tích và hiểu ý nghĩa của yêu cầu từ những từ này, đồng thời sử dụng tính năng so khớp thiết bị để cung cấp ngữ cảnh cho yêu cầu. Bối cảnh này rất quan trọng vì nó xác định những thao tác mà thiết bị hỗ trợ và cách thực hiện những thao tác này.
Sau đó, dịch vụ sẽ phản hồi bằng văn bản được nói lại cho người dùng (Chắc chắn rồi.) cùng với lệnh dành riêng cho thiết bị. Thiết bị biết cách xử lý lệnh này: thiết bị sẽ bật đèn LED!

Bắt đầu
Hiện thực hoá ý tưởng của bạn bằng cách nhúng Trợ lý Google vào dự án, sau đó thêm chức năng riêng biệt bằng Device Actions. Bạn có thể phát triển dự án của mình bằng dịch vụ Trợ lý Google.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\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)."]]