Kể từ ngày 13 tháng 6 năm 2023, Hành động trò chuyện không còn được dùng nữa. Để biết thêm thông tin, hãy xem phần Hành động trò chuyện ngừng hoạt động.
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.
Sau khi chạy Trợ lý Google trên dự án của bạn, hãy thử các cách sau:
Tuỳ chỉnh cách dự án của bạn tương tác với Trợ lý. Ví dụ: kích hoạt Trợ lý bằng cách nhấn một nút hoặc nhấp nháy đèn LED khi phát lại âm thanh. Thậm chí, bạn có thể hiển thị bản chép lời nhận dạng lời nói từ Trợ lý trên màn hình.
Kiểm soát dự án của bạn bằng các lệnh tuỳ chỉnh.
Ví dụ: yêu cầu trình làm cocktail có Trợ lý làm đồ uống yêu thích của bạn.
Tuỳ chỉnh cách dự án của bạn tương tác với Trợ lý
Kích hoạt Trợ lý
Với Google Assistant Service API (API Dịch vụ Trợ lý Google), bạn có thể kiểm soát thời điểm kích hoạt yêu cầu của Trợ lý. Sửa đổi mã mẫu để kiểm soát việc này (ví dụ: khi nhấn một nút). Bạn có thể kích hoạt yêu cầu của Trợ lý bằng cách gửi yêu cầu đến EmbeddedAssistant.Assist.
Nhận bản chép lời yêu cầu của người dùng
SDK Trợ lý Google cung cấp cho bạn một bản chép lời của yêu cầu của người dùng. Hãy sử dụng tính năng này để đưa ra ý kiến phản hồi cho người dùng bằng cách hiển thị văn bản lên màn hình hoặc thậm chí là cho một hành động sáng tạo hơn như thực hiện một số thao tác cục bộ trên thiết bị.
SDK Trợ lý Google cung cấp cho bạn văn bản thuần tuý của câu trả lời của Trợ lý. Hãy sử dụng tính năng này để đưa ra ý kiến phản hồi cho người dùng bằng cách kết xuất văn bản lên màn hình.
SDK Trợ lý Google hỗ trợ hiển thị phản hồi của Trợ lý cho một màn hình trong trường hợp có phản hồi bằng hình ảnh cho một số truy vấn nhất định. Ví dụ: cụm từ tìm kiếm Thời tiết ở Mountain View như thế nào? sẽ hiển thị nhiệt độ hiện tại, hình ảnh minh hoạ thời tiết và các nội dung đề xuất cho các cụm từ tìm kiếm liên quan. Dữ liệu HTML5 này (nếu có) nằm trong trường ScreenOut.data nếu bạn bật tính năng này.
Bạn có thể bật tính năng này trong mẫupushtotalk.py và textinput.py bằng cờ dòng lệnh --display. Dữ liệu sẽ hiển thị trong cửa sổ trình duyệt.
Gửi truy vấn thông qua tính năng nhập văn bản
Nếu bạn đã gắn giao diện văn bản (ví dụ: bàn phím) vào thiết bị, hãy đặt trường text_query trong trường config (xem AssistConfig). Đừng đặt trường audio_in_config.
Mã mẫu bao gồm tệp textinput.py. Bạn có thể chạy tệp này để gửi truy vấn thông qua phương thức nhập văn bản.
Gửi truy vấn thông qua đầu vào tệp âm thanh
Mã mẫu bao gồm tệp audiofileinput.py. Bạn có thể chạy tệp này để gửi truy vấn thông qua tệp âm thanh. Mẫu sẽ xuất ra một tệp âm thanh có phản hồi của Trợ lý.
Kiểm soát dự án của bạn bằng các lệnh tuỳ chỉnh
Bạn có thể thêm các lệnh tuỳ chỉnh vào Trợ lý để điều khiển dự án của mình thông qua giọng nói.
Tạo một công thức IFTTT cho Trợ lý. Sau đó, hãy định cấu hình IFTTT để tạo một yêu cầu HTTP tuỳ chỉnh đến một điểm cuối mà bạn chọn để phản hồi lệnh của Trợ lý. Để thực hiện việc này, hãy sử dụng các thao tác IFTTT của Trình tạo.
[[["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\u003eCustomize interactions with the Google Assistant, such as triggering it with a button or displaying speech recognition transcripts.\u003c/p\u003e\n"],["\u003cp\u003eControl your projects using custom commands through Device Actions or IFTTT recipes.\u003c/p\u003e\n"],["\u003cp\u003eAccess the Assistant's response in various formats like text, HTML for visual responses, and audio.\u003c/p\u003e\n"],["\u003cp\u003eSubmit queries to the Assistant using either text input (like a keyboard) or audio files.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the provided sample code and documentation to integrate these features into your projects.\u003c/p\u003e\n"]]],[],null,["# Next Steps\n\nOnce you have the Google Assistant running on your project, give these a try:\n\n1. [Customize](#custom-interaction) how your project interacts with the\n Assistant. For example, trigger the Assistant with the push of a button or\n blink an LED when playing back audio. You can even show a speech recognition\n transcript from the Assistant on a display.\n\n2. [Control](#device-control) your project with custom commands.\n For example, ask your Assistant-enabled [mocktail maker](http://deeplocal.com/mocktailsmixer/)\n to make your favorite drink.\n\nCustomize how your project interacts with the Assistant\n-------------------------------------------------------\n\n### Trigger the Assistant\n\nWith the Google Assistant Service API, you control when to trigger an Assistant\nrequest. Modify the [sample code](https://github.com/googlesamples/assistant-sdk-python/tree/master/google-assistant-sdk/googlesamples/assistant/grpc)\nto control this (for example, at the push of a button). Triggering\nan Assistant request is done by sending a request to [`EmbeddedAssistant.Assist`](/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#google.assistant.embedded.v1alpha2.EmbeddedAssistant.Assist).\n\n### Get the transcript of the user request\n\nThe Google Assistant SDK gives you a text transcript of the user request. Use\nthis to provide feedback to the user by rendering the text to a display, or even\nfor something more creative such as performing some local actions on the device.\n\nThis transcript is located in the [`SpeechRecognitionResult.transcript`](/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#speechrecognitionresult) field.\n\n### Get the text of the Assistant's response\n\nThe Google Assistant SDK gives you the plain text of the Assistant response. Use this\nto provide feedback to the user by rendering the text to a display.\n\nThis text is located in the [`DialogStateOut.supplemental_display_text`](/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#dialogstateout)\nfield.\n\n### Get the Assistant's visual response\n\nThe Google Assistant SDK supports rendering the Assistant response to a\ndisplay in the case of visual responses to certain queries. For example,\nthe query *What is the weather in Mountain View?* will render the current\ntemperature, a pictorial representation of the weather, and suggestions for\nrelated queries. This HTML5 data (if present) is located in the\n[`ScreenOut.data`](/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#screenout) field if this feature is [enabled](/assistant/sdk/guides/service/integrate#text-response).\n\nThis can be enabled in the `pushtotalk.py` and `textinput.py` [samples](https://github.com/googlesamples/assistant-sdk-python/tree/master/google-assistant-sdk/googlesamples/assistant/grpc)\nwith the `--display` command line flag. The data is rendered in a browser window.\n| **Note:** If you are sending commands over SSH to a Raspberry Pi with a connected display, make sure you run `export DISPLAY=:0` before running the sample with the `--display` command line flag.\n\n### Submitting queries via text input\n\nIf you have a text interface (for example, a keyboard) attached to the device,\nset the `text_query` field in the `config` field (see [`AssistConfig`](/assistant/sdk/reference/rpc/google.assistant.embedded.v1alpha2#assistconfig)).\nDo not set the `audio_in_config` field.\n\nThe [sample code](https://github.com/googlesamples/assistant-sdk-python/tree/master/google-assistant-sdk/googlesamples/assistant/grpc)\nincludes the file `textinput.py`. You can run this file to submit queries via\ntext input.\n\n### Submitting queries via audio file input\n\nThe [sample code](https://github.com/googlesamples/assistant-sdk-python/tree/master/google-assistant-sdk/googlesamples/assistant/grpc)\nincludes the file `audiofileinput.py`. You can run this file to submit a query\nvia an audio file. The sample outputs an audio file with the Assistant's response.\n\nControl your project with custom commands\n-----------------------------------------\n\nYou can add custom commands to the Assistant that allow you to control your\nproject via voice.\n\nHere are two ways to do this:\n\n- Extend the Google Assistant Service sample to include [Device Actions](/assistant/sdk/guides/service/python/extend/install-hardware).\n\n- Create an [IFTTT recipe](https://support.google.com/googlehome/answer/7194656)\n for the Assistant. Then configure IFTTT to make a custom HTTP request to an\n endpoint you choose in response to an Assistant command. To do so, use\n [Maker IFTTT actions](http://maker.ifttt.com)."]]