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.
Để xác định Hành động trong Dialogflow, bạn hãy tạo ý định trong nhân viên hỗ trợ Dialogflow và gán ý định đó dưới dạng điểm truy cập cho Hành động của mình. Bạn có thể tạo các loại Hành động sau:
Hành động mặc định: Mỗi nhân viên hỗ trợ Dialogflow phải có một và chỉ một Hành động được gọi khi người dùng yêu cầu Hành động của bạn theo tên (ví dụ: "Ok Google". Trò chuyện với Thông tin về Google" hoặc "Ok, Google. Hãy để tôi nói với
Dữ liệu về Google").
Ý định bổ sung để liên kết sâu vào cuộc trò chuyện của bạn: Những Hành động này được kích hoạt khi người dùng gọi Hành động của bạn theo tên và chỉ định một cụm từ gọi (ví dụ: "trò chuyện với Thông tin về Google để biết dữ kiện nhật ký").
Vui lòng xem bài viết Ý định và lệnh gọi để biết thêm thông tin về cách hoạt động của các mô hình gọi này.
Xác định Hành động mặc định
Mỗi nhân viên hỗ trợ Dialogflow phải có một và chỉ một ý định để xử lý sự kiện GOOGLE_ASSISTANT_WELCOME. Ý định này được kích hoạt khi người dùng gọi Hành động của bạn bằng tên của Hành động đó (ví dụ: "Ok Google, hãy trao đổi với Các thông tin về Google").
Bạn có thể xác định sự kiện GOOGLE_ASSISTANT_WELCOME theo những cách sau:
Từ trình chỉnh sửa ý định trên bảng điều khiển Dialogflow:
Nhấp vào Ý định trong trình đơn điều hướng.
Chọn ý định mà bạn muốn đặt làm sự kiện chào mừng.
Trong phần Sự kiện của ý định, hãy nhập GOOGLE_ASSISTANT_WELCOME.
Nhấp vào Lưu.
Hình 1 Ảnh chụp màn hình mục Sự kiện của một ý định Dialogflow.
Trên cửa sổ chế độ tích hợp Trợ lý Google:
Nhấp vào Tích hợp trong trình đơn điều hướng rồi nhấp vào Trợ lý Google.
Nhấp vào dấu X để xoá mục hiện tại trong trường Lời gọi rõ ràng.
Trong hộp Ý định chào mừng, hãy chọn ý định mà bạn muốn đặt làm sự kiện chào mừng.
Hình 2. Ảnh chụp màn hình cửa sổ tích hợp Trợ lý Google trên bảng điều khiển Dialogflow.
Khi xem phần Sự kiện của ý định, bạn sẽ thấy ý định đó hiện đã có nhóm sự kiện GOOGLE_UNSUPPORTEDANT_WELCOME (xem Hình 1).
Bật phương thức thực hiện
Theo mặc định, một ý định Dialogflow sẽ trả về phản hồi tĩnh, được chỉ định trong mục Phản hồi của ý định. Cài đặt này có thể đủ cho các Hành động đơn giản chỉ cần phản hồi bằng cùng một thông báo khi được gọi. Tuy nhiên, nếu muốn ý định trả về một phản hồi động, bạn cần cung cấp phương thức thực hiện có thể xử lý logic phức tạp và soạn phản hồi theo thời gian thực cho ý định đó.
Để bật phương thức thực hiện cho một ý định, hãy làm như sau:
Di chuyển xuống cuối trình chỉnh sửa ý định của một ý định.
Nhấp vào Thực hiện rồi chọn Bật lệnh gọi webhook cho ý định này.
Hình 3. Ảnh chụp màn hình phần Thực hiện đơn hàng của một ý định Dialogflow.
Bạn có thể cung cấp các Hành động khác để làm điểm truy cập vào cuộc trò chuyện. Cách thiết lập này cho phép người dùng chỉ định thêm thông tin chi tiết về những việc họ muốn làm (ví dụ: "Trò chuyện với Thông tin về Google để tìm thông tin về nhật ký cho tôi").
Để xác định các Hành động khác trong Dialogflow, hãy làm theo các bước sau:
Tạo ý định cho một Hành động cụ thể mà bạn muốn tạo.
Trong phần Cụm từ huấn luyện của ý định, hãy chỉ định các mẫu kích hoạt Hành động này. Ví dụ: nếu bạn muốn gọi Hành động bằng cụm từ "Trò chuyện với thông tin về Google để tìm thông tin về lịch sử", hãy cung cấp Cụm từ đào tạo sau:
"Tìm cho tôi thông tin về lịch sử"
"Tra cứu thông tin lịch sử"
"Xem thông tin thực tế về lịch sử công ty"
"Đọc cho tôi một số thông tin về trụ sở chính"
"Cho tôi biết một vài thông tin về trụ sở chính"
Bạn nên sử dụng ít nhất 10 cụm từ huấn luyện cho mỗi ý định.
Để bật phương thức thực hiện cho ý định, hãy cuộn xuống cuối màn hình, nhấp vào Fulfillment (Thực hiện) rồi chọn Enable webhook call for this intent (Bật lệnh gọi webhook cho ý định này).
(Xem bài viết Phương thức thực hiện bản dựng để biết thêm thông tin về phương thức thực hiện.)
Nhấp vào Lưu.
Nhấp vào Tích hợp trong trình đơn điều hướng rồi nhấp vào Trợ lý Google.
(cửa sổ phụ Trợ lý Google sẽ xuất hiện.)
Trong mục Lời gọi ngầm ẩn, hãy thêm ý định.
Hình 4. Ảnh chụp màn hình phần Lệnh gọi ngầm ẩn trên cửa sổ phương thức tích hợp Trợ lý Google.
Khi xác định Hành động, các hạn chế và nguyên tắc sau sẽ áp dụng:
Đừng thêm các từ dành riêng vào các cụm từ của lời gọi.
Ví dụ: đừng bắt đầu các cụm từ của lời gọi bằng "trò chuyện với" hoặc "hãy để tôi nói chuyện".
Đừng chỉ định các cụm từ huấn luyện chỉ chứa một thực thể @sys.any.
Hãy cụ thể hơn nhiều; ví dụ: find recipes for @sys.any.
Xử lý Hành động không nhận dạng được
Khi người dùng cố gọi một Hành động mà Hành động của bạn không nhận ra, Dialogflow có thể kích hoạt một ý định để xử lý những trường hợp này.
Để kích hoạt hành vi này, hãy tạo một ý định mới với ngữ cảnh đầu vào là google_assistant_welcome và chỉ định các phản hồi thích hợp cho người dùng:
Trong trình đơn điều hướng, hãy nhấp vào Ý định.
Nhấp vào Tạo ý định rồi đặt tên cho ý định.
Trong phần Ngữ cảnh, hãy chỉ định google_assistant_welcome làm ngữ cảnh nhập rồi nhấn phím Enter. (Sau khi nhập ngữ cảnh đầu vào, google_assistant_welcome sẽ xuất hiện dưới dạng ngữ cảnh đầu ra).
Nhấp vào x để xoá ngữ cảnh đầu ra đó.
Trong Cụm từ huấn luyện, hãy thêm banana (hoặc bất kỳ danh từ nào khác) làm biểu thức người dùng.
Nhấp đúp vào chuối rồi chọn @sys.any. (Chúng tôi sử dụng thực thể @sys.any
để yêu cầu Dialogflow khái quát biểu thức này cho bất kỳ ngữ pháp nào, chứ không chỉ chuối.)
Trong phần Response (Phản hồi), hãy chỉ định một câu trả lời bằng cách sử dụng $any. Ví dụ: sử dụng phản hồi sau:
[[["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\u003eDialogflow Actions are entry points into your Google Action, defined by intents, with a mandatory default Action triggered when users invoke your Action by name.\u003c/p\u003e\n"],["\u003cp\u003eAdditional intents can be created to handle deep links, allowing users to specify invocation phrases for more detailed requests.\u003c/p\u003e\n"],["\u003cp\u003eFulfillment can be enabled for intents to provide dynamic responses based on complex logic and real-time processing.\u003c/p\u003e\n"],["\u003cp\u003eWhen unrecognized Actions are invoked, Dialogflow can trigger a specific intent to handle these scenarios, using input context and the \u003ccode\u003e@sys.any\u003c/code\u003e entity for generalization.\u003c/p\u003e\n"],["\u003cp\u003eIt is generally recommended to utilize fallback intents to reprompt users for invalid input instead of overriding Assistant's default no-match behavior.\u003c/p\u003e\n"]]],["Dialogflow Actions are defined by creating intents in a Dialogflow agent. A **Default Action**, triggered by the Action's name, is mandatory, utilizing the `GOOGLE_ASSISTANT_WELCOME` event. Additional Actions allow deeper linking with specific invocation phrases. To define these, create intents with relevant training phrases, enable webhook fulfillment for dynamic responses, and add them to the Google Assistant integration. Handling unrecognized actions involves creating an intent with `google_assistant_welcome` input context, using `@sys.any` for general expressions.\n"],null,["# Define Actions (Dialogflow)\n\nTo define Actions in Dialogflow, you create intents in your Dialogflow agent and\nassign them as entry points into your Action. You can create the following types\nof Actions:\n\n- **Default Action** : Every Dialogflow agent must have one and only one Action that's invoked when users ask for your Action by name (for example, *\"Ok\n Google. Talk to Facts about Google\"* or *\"Ok, Google. Let me talk to Facts\n about Google\"*).\n- **Additional intents to deep link into your conversation** : These Actions are triggered when users invoke your Action by its name **and** specify an invocation phrase (for example, *\"talk to Facts about Google for history\n facts\"*).\n\nSee [Intents and invocation](/assistant/df-asdk/discovery) for more information on how\nthese invocation models work.\n\nDefine a default Action\n-----------------------\n\n| **Dialogflow Tip**\n|\n| Because Dialogflow supports many products, there are\n| welcome event triggers for specific platforms, such as\n| **GOOGLE_ASSISTANT_WELCOME** for Actions. The generic\n| **WELCOME** event lets you handle invocations across many platforms if you\n| deploy the agent on multiple platforms.\n\nEvery Dialogflow agent must have one and only one intent that handles\nthe **GOOGLE_ASSISTANT_WELCOME** event. This intent is triggered\nwhen users invoke your Action by its name (for example, *\"Ok Google, talk to\nFacts about Google\"*).\n\nYou can define the **GOOGLE_ASSISTANT_WELCOME** event in\nthe following ways:\n\n**From the intent editor on the Dialogflow console:**\n\n1. Click **Intents** in the navigation menu.\n2. Select the intent that you want to set as the welcome event.\n3. In the **Events** section of the intent, enter `GOOGLE_ASSISTANT_WELCOME`.\n4. Click **Save**.\n\n **Figure 1**. A screenshot of the Events section of a Dialogflow intent.\n\n**From the Google Assistant integration modal window:**\n\n1. Click **Integrations** in the navigation menu and click **Google Assistant**.\n2. Click **X** to remove the current item in the **Explicit invocation** field.\n3. In the **Welcome intent** box, select the intent that you want to set as the\n welcome event.\n\n **Figure 2**. A screenshot of the Google Assistant integration modal window\n on the Dialogflow console.\n\nWhen you view the intent's **Events** section, you should see that the intent\nnow has the **GOOGLE_ASSISTANT_WELCOME** event set (see **Figure 1**).\n\n### Enable fulfillment\n\nBy default, a Dialogflow intent returns a static response, which is specified\nin **Response** section of the intent. This setting might be enough for simple\nActions that only need to respond with the same message when invoked. However,\nif you want the intent to return a dynamic response, you need to provide\nfulfillment that can process complex logic and compose a response in real time\nfor the intent.\n\nTo enable fulfillment for an intent, do the following:\n\n1. Scroll to the bottom of the intent editor of an intent.\n2. Click **Fulfillment** and select **Enable webhook call for this intent**.\n\n **Figure 3**. A screenshot of the Fulfillment section of a Dialogflow intent.\n\nSee [Build fulfillment](/assistant/df-asdk/dialogflow/fulfillment) for information on how to handle this\nintent when it's triggered.\n\nDefine additional Actions\n-------------------------\n\nYou can provide additional Actions that act as entry points into your\nconversation. This setup allows users to specify more details about what they\nwant to do (for example, *\"Talk to Facts about Google to find me history\nfacts\"*).\n\nTo define additional Actions in Dialogflow, follow these steps:\n\n1. Create an intent for a specific Action that you want to build.\n2. In the intent's **Training phrases** section, specify the patterns that\n trigger this Action. For example, if you want the Action to be invoked by the\n phrase *\"Talk to Facts about Google to find me history facts\"* , provide the\n following *Training phrases*:\n\n - *\"Find me history facts\"*\n - *\"Look up history facts\"*\n - *\"Get me facts about history of the company\"*\n - *\"Read me some headquarters facts\"*\n - *\"Tell me a few facts about its headquarters\"*\n\n We recommend at least 10 training phrases per intent.\n3. To enable fulfillment for the intent, scroll to the bottom of the screen,\n click **Fulfillment** , and select **Enable webhook call for this intent** .\n (See [Build fulfillment](/assistant/df-asdk/dialogflow/fulfillment) for more details on\n fulfillment.)\n\n4. Click **Save**.\n\n5. Click **Integrations** in the navigation menu and click **Google Assistant**.\n (the Google Assistant modal window appears.)\n\n6. In the **Implicit invocation** section, add the intent.\n\n **Figure 4**. A screenshot of the Implicit invocation section on the Google\n Assistant integration modal window.\n\nWhen defining Actions, the following restrictions and guidelines apply:\n\n- Don't include the *reserved words* in invocation phrases.\n - For example, don't start your invocation phrases with *\"talk to\"* or \"let me talk to\".\n- Don't specify training phrases that contain only a `@sys.any` entity.\n - Be much more specific; for example, `find recipes for @sys.any`.\n\nHandling an unrecognized Action\n-------------------------------\n\nWhen users attempt to invoke an Action that your Actions don't recognize,\nDialogflow can trigger an intent to handle these cases.\n| **Warning:** You should avoid globally overriding Assistant's [default no-match behavior](#no-match_yielding), as it may negatively impact the ability of users to move between Actions. Generally, your Action should *not* try to handle all no-match and no-input scenarios. We recommend using [fallback intents](/assistant/df-asdk/dialogflow/fulfillment#no-match_reprompting) to reprompt the user when your Action receives invalid input.\n\nTo enable this behavior,\ncreate a new intent with an input context of `google_assistant_welcome` and\nspecify the appropriate responses to users:\n\n1. In the navigation menu, click **Intents**.\n2. Click **Create Intent** and name your intent.\n3. In the **Contexts** section, Specify `google_assistant_welcome` as the input context and press enter key. (After entering the input context, `google_assistant_welcome` appears as an output context).\n4. Click **x** to remove that output context.\n\n5. In the **Training phrases** , add `banana` (or any other noun) as a user\n expression.\n\n6. Double-click on **banana** and select `@sys.any`. (We use the `@sys.any`\n entity to tell Dialogflow to generalize the expression to any grammar, not\n just *banana*.)\n\n7. In the **Response** section, specify a responses using `$any`. For example,\n use the following response:\n\n - `I'm sorry, I don't know how to help with $any.`\n\n8. Click **Save**.\n\n| **Note:** While you can use Dialogflow to return simple text responses as a fallback, you can turn on **Enable webhook call for this intent** and provide more advanced fulfillment in your webhook code."]]