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.
Gửi một truy vấn bằng văn bản đến hành động trò chuyện.
Tham số
textQuery
string
Truy vấn gửi đến hành động trò chuyện.
state
string
Một trong số sau:
READY: Nền tảng có thể chấp nhận yêu cầu.
BLOCKED: Có một truy vấn đang bay và truy vấn mới sẽ bị loại bỏ.
UNKNOWN: Không thể xác định trạng thái hiện tại của truy vấn.
getHeaderHeightPx
getHeaderHeightPx() returns Promise<height>
Xác định chiều cao của tiêu đề ở đầu màn hình.
Tham số
height
number
Chiều cao tính bằng pixel.
InteractiveCanvasCallbacks
Các lệnh gọi lại này cung cấp cho bạn cách thức phản hồi thông tin hoặc yêu cầu
từ hành động trò chuyện trong khi các phương thức cung cấp cách gửi
thông tin hoặc yêu cầu đối với hành động trò chuyện.
onUpdate
onUpdate(data) returns undefined
Được gọi khi một HtmlResponse được gửi từ hành động trò chuyện. Sau
khi kết thúc lệnh gọi hàm, TTS sẽ bắt đầu ngay lập tức.
Tham số
data
Object
Dữ liệu cập nhật do webhook gửi.
onTtsMark
onTtsMark(markName) returns undefined
Lệnh gọi lại được gọi trong khi phát TTS.
Các dấu đặc biệt luôn được kích hoạt:
START cho biết phần đầu của TTS.
END cho biết phần cuối của TTS.
ERROR cho biết đã xảy ra lỗi khi phát TTS.
Bạn cũng có thể xác định nhãn tuỳ chỉnh bằng cách sử dụng
SSML
và thẻ <mark>, chẳng hạn như <mark name="custom"/>.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eConditional logic in scenes uses values from intent, scene, session, user, home, device, canvas, and resource objects.\u003c/p\u003e\n"],["\u003cp\u003eSupported operations include logical (&&, ||, !), numerical (+, -, *, /), comparison (==, !=, <, <=, >, >=), and operations on lists and maps.\u003c/p\u003e\n"],["\u003cp\u003eBoolean constants \u003ccode\u003etrue\u003c/code\u003e, \u003ccode\u003efalse\u003c/code\u003e, and \u003ccode\u003e!false\u003c/code\u003e are available, and string operations support double or single quotes, substring checks, concatenation, lexicographical comparison, and size calculation.\u003c/p\u003e\n"],["\u003cp\u003eData model objects like \u003ccode\u003eintent\u003c/code\u003e, \u003ccode\u003esession\u003c/code\u003e, and others provide access to various data points for conditional checks, and these values can also be referenced in static prompts.\u003c/p\u003e\n"]]],[],null,["# InteractiveCanvas (Dialogflow)\n\nThe `interactiveCanvas` object is the interface to your conversational action\nthat is made available within your web app.\n| **Note:** The `interactiveCanvas` object is attached to the `window` object. If you are using a front-end framework to develop your web app, you need to ensure that you have access to `window` to set up the API.\n\nMethods\n-------\n\n### ready\n\n ready(callbacks) returns undefined\n\nCalled by the Interactive Canvas web app once it has loaded to register callbacks.\n\n| Parameters ||\n|-------------|-----------------------------------------------------------------------------------------------------------|\n| `callbacks` | ` `[InteractiveCanvasCallbacks](#interactivecanvascallbacks)` ` An object that contains method callbacks. |\n\n| **Note:** You must invoke the `ready` API in the web app as soon as the page is loaded. Otherwise, the Action will close.\n\n### sendTextQuery\n\n sendTextQuery(textQuery) returns Promise\u003cstate\u003e\n\nSends a text query to the conversational action.\n\n| Parameters ||\n|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `textQuery` | `string` The query to send to the conversational action. |\n| `state` | `string` One of the following: `READY:` Requests can be accepted by the platform. `BLOCKED:` There is a query in flight and the new query will be dropped. `UNKNOWN:` The current query state couldn't be determined. \u003cbr /\u003e |\n\n| **Caution:** `textQuery` must be 640 characters or less.\n\n### getHeaderHeightPx\n\n getHeaderHeightPx() returns Promise\u003cheight\u003e\n\nDetermines the height of the header at the top of a display.\n\n| Parameters ||\n|----------|--------------------------------|\n| `height` | `number` The height in pixels. |\n\nInteractiveCanvasCallbacks\n--------------------------\n\nThese callbacks provide a way for you to respond to information or requests\nfrom your conversational action while the methods provide a way to send\ninformation or requests to your conversational action.\n\n### onUpdate\n\n onUpdate(data) returns undefined\n\nCalled when an `HtmlResponse` is sent from the conversational action. After\nthe end of the function call, the TTS will start immediately.\n\n| Parameters ||\n|--------|--------------------------------------------|\n| `data` | `Object` Updated data sent by the webhook. |\n\n### onTtsMark\n\n onTtsMark(markName) returns undefined\n\nCallback that is invoked during TTS playback.\n\nSpecial marks that always are triggered:\n\n- `START` indicates the start of the TTS.\n- `END` indicates the end of the TTS.\n- `ERROR` indicates an error playing the TTS.\n\nYou can also define custom marks by using\n[SSML](/assistant/actions/reference/ssml)\nand the `\u003cmark\u003e` tag, like `\u003cmark name=\"custom\"/\u003e`.\n| **Note:** SSML marks are not invoked when the following occurs:\n|\n| - Before TTS begins, the user taps the microphone, or the Interactive Canvas client invokes `sendTextQuery`. The TTS is cancelled and any SSML marks in the TTS are ignored.\n| - During TTS, the user taps the microphone, or the Interactive Canvas client invokes `sendTextQuery`. The TTS is interrupted and any remaining SSML marks in the TTS are ignored.\n\n| Parameters ||\n|------------|-------------------------------------------------|\n| `markName` | `string` Mark name invoked during TTS playback. |"]]