对话型 Action 允许开发者为使用 Google 助理的用户创建自定义体验或对话,从而扩展了 Google 助理的功能。在对话中,对话型 Action 会处理来自 Google 助理的请求,并返回包含音频和视觉组件的响应。对话型 Action 还可以连接到外部服务,以增加对话或业务逻辑,然后再返回响应。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eConversational Actions let developers build custom experiences for Google Assistant, handling user requests and returning responses with audio and visual elements.\u003c/p\u003e\n"],["\u003cp\u003eDialogflow is highly recommended for building Conversational Actions as it handles natural language processing, while the Actions SDK requires developers to provide their own NLU solution.\u003c/p\u003e\n"],["\u003cp\u003eBuilding a Conversational Action involves designing the conversation flow and building the conversation fulfillment, which can be done using Dialogflow or the Actions SDK.\u003c/p\u003e\n"],["\u003cp\u003eDialogflow integrates with Conversational Actions to handle natural language understanding, parsing user requests, and triggering corresponding actions.\u003c/p\u003e\n"],["\u003cp\u003eResponses in Conversational Actions can range from simple text to rich media, allowing developers to create engaging experiences across different surfaces.\u003c/p\u003e\n"]]],[],null,["# Conversational Actions (Dialogflow)\n\n| **Note:** This section of documentation focuses on integrating Dialogflow and Google Assistant. For the latest documentation about converational actions, see the [conversational actions overview](/assistant/conversational/overview).\n\nConversational Actions extend the functionality of the Google Assistant by\nallowing developers to create custom experiences, or conversations, for users on\nthe Assistant. In a conversation, your Conversational Action handles requests from the\nAssistant and returns responses with audio and visual components. Conversational Actions\ncan also connect to external services for added conversational or business logic\nbefore returning a response.\n\nFor example, users can invoke your Conversational Action to get a response from your\nexternal fulfillment service when they want to look up information, get a\npersonalized recommendation, or perform transactions involving digital payments.\n**Figure 1.** An example of a Conversational Action\n\nUse cases\n---------\n\nConversational Actions work best for simple use cases that complement another experience.\nGood Conversational Actions often fall into these general categories:\n\n- **Things people can easily answer.** Actions that can be accomplished with familiar input like times or dates, like booking a flight.\n- **Quick, but compellingly useful Actions.** These usually give users immediate benefit for very little time spent, like finding out when their favorite sports team plays next.\n- **Actions that are inherently better suited for voice.** These are typically things you want to do hands-free, like receiving coaching during yoga or light exercise.\n\nHow Conversational Actions work\n-------------------------------\n\nUnlike with traditional mobile and desktop apps, which use computer-centric\nparadigms, users interact with Actions for the Assistant through\nnatural-sounding, back and forth conversation. Conversational Actions begin when invoked by a\nuser and continue until the user chooses to exit (using predetermined phrases)\nor your Conversational Action denotes the end of the conversation.\n\nDuring a conversation, user inputs are transformed from speech to text by the\nAssistant, and formed into JSON requests for natural language processing. These\nrequests are sent to what's known as your **conversation fulfillment**.\n\nYour conversation fulfillment parses the user's query into structured data,\nprocesses that data, and returns a webhook JSON response to the Assistant. The\nAssistant then processes and presents your response to the user.\n**Figure 2.** Conversation fulfillment is a JSON in-JSON out system\n\nBuilding your own natural language processing service can be challenging, so we\nprovide Dialogflow as a way to handle it for you. For developers who cannot use\nDialogflow, we also provide the Actions SDK as a backup option with a separate,\nbut related, development path.\n| **Caution:** Using the Actions SDK requires you to build or provide your own NLU solution. Although both Dialogflow and the Actions SDK are covered in the custom Actions documentation, we **highly** recommend using Dialogflow. The development experience changes significantly for Conversational Actions depending on what you use for conversation fulfillment.\n\nOnce you set up an agent in Dialogflow, your conversation fulfillment is\naugmented by Dialogflow's features, including the ability to use Dialogflow\nfulfillment. This approach allows you to isolate conversation fulfillment from\nother services you may need to provide users with their desired outcome.\n**Figure 3.** Conversation fulfillment when using Dialogflow\n\nBuilding a Conversational Action\n--------------------------------\n\nMost of building your Conversational Action is designing the conversation and building your\nconversation fulfillment. Think of the conversation as the user interface for\nyour Conversational Action. You need to think about how users invoke your Actions project,\nthe valid things that they can say in a conversation, and how your Actions\nproject responds to them.\n\nIn your Actions project, you provide metadata for publishing the project and\nspecify a method of conversation fulfillment. Developers using Dialogflow\nassociate their Dialogflow agent with the project, then build fulfillment\nthrough Dialogflow. For developers using the Actions SDK, building conversation\nfulfillment involves coding and deploying in the [conversation webhook format](/assistant/df-asdk/reference/conversation-webhook-json).\n\nWhen designing your conversation, we recommend using our processes and [design\nprinciples](/assistant/df-asdk/design). Conversational interfaces are still a relatively new technology, and\nlearning about best practices can save you time in the future.\n\n### Fulfillment using Dialogflow\n\nWhen integrating with a Dialogflow agent, the agent handles NLU for user queries\nin your Conversational Action. Your Dialogflow agent does the following for you during this\nstep:\n\n1. Parses each incoming request from the Assistant based on training phrases you provide and conversational context.\n2. Matches each request to a Dialogflow intent (also known as an event).\n3. Extracts parameters into Dialogflow entities.\n\nYour Dialogflow agent can then call on its own fulfillment (deployed as a\nwebhook) to carry out some logic like calling a REST API or other backend\nservice that generates a response to return to the Assistant. This webhook is\nalso known as your Dialogflow fulfillment, and uses the [Dialogflow webhook format](/assistant/df-asdk/reference/dialogflow-webhook-json).\n**Figure 4.** A Dialogflow agent parses a user query into structured data for Dialogflow fulfillment\n\nBuilding conversation fulfillment when using Dialogflow primarily consists of\ndeveloping your Dialogflow fulfillment webhook. In the Actions on Google\ndocumentation, you'll find resources to help you design, build, and test your\nDialogflow fulfillment webhook. Most notably, those resources include the\n[Node.js client library](/assistant/df-asdk/reference/nodejsv2/overview) and the [Java client library](/assistant/df-asdk/reference/java/overview).\n\nAs you build with Dialogflow, you'll use the Dialogflow Console to create\nDialogflow intents, entities, and training phrases.\n| **Note:** Terminology in Actions on Google and Dialogflow can sometimes be very similar, but they represent different sets of information. For example, intents (and built-in intents) in Actions on Google are distinct from Dialogflow intents and instead map to *events* in Dialogflow.\n\nFor more general information about Dialogflow, you can read about the Actions on\nGoogle integration in the [Dialogflow documentation](//dialogflow.com/docs/integrations/actions/integration).\n\n### Fulfillment using Actions SDK\n\nBuilding conversation fulfillment with the Actions SDK primarily consists of\ncreating and deploying your Action package. Action packages are created in the\n[`ActionPackage`](/assistant/conversational/reference/rest/Shared.Types/ActionPackage) format and use the [conversation webhook format](/assistant/df-asdk/reference/conversation-webhook-json).\nAn Action package contains all Actions for a given Actions project.\n\nThe Assistant provides user queries to your conversation fulfillment using\nActions on Google intents. For each intent, your fulfillment webhook must parse\nthe intent, process it, and return a JSON response to the Assistant for the\nuser.\n\n### Responses\n\nWhen you build an Action for the Assistant, you design your conversations for a\nvariety of surfaces, such as a voice-centric conversation for voice-activated\nspeakers or a visual conversation on a surface that the Assistant supports. This\napproach lets users get things done quickly through either voice or visual\naffordances.\n\nAs you build your fulfillment, you can select from a variety of engaging\nresponse types for the Assistant to present to users. These range from chat\nbubbles containing simple text to media responses, carousels, and even [HTML\nusing Interactive Canvas](/assistant/interactivecanvas).\n| **Note:** To design and build conversations that work well on all surfaces, use [surface capabilities](/assistant/df-asdk/surface-capabilities) to control and scope your conversations properly.\n\nNext steps\n----------\n\nFollow the [Build Actions for the Google Assistant (Level 1)](//codelabs.developers.google.com/codelabs/actions-1/#0)\ncodelab for detailed step-by-step instructions to begin building your first\nConversational Action.\n\nThen, you can continue on to our guides for building your own conversation\nfulfillment [with Dialogflow](/assistant/df-asdk/dialogflow) or [with the Actions SDK](/assistant/df-asdk/actions-sdk).\nYou can also explore these additional resources for building Conversational Actions:\n\n- [Actions on Google GitHub repo](//github.com/actions-on-google): Sample code and libraries.\n- [r/GoogleAssistantDev](//www.reddit.com/r/GoogleAssistantDev): The official Reddit community for developers working with the Google Assistant."]]