以下代码段显示了一个对话 webhook (JSON) 示例
当用户说出您的 Action“What's the Air quality in
San Francisco tomorrow?”:
"inputs":[{"intent":"actions.intent.CHECK_AIR_QUALITY","rawInputs":[{"inputType":"VOICE","query":"what is the air quality in san francisco tomorrow"}],"arguments":[{"name":"location","structuredValue":{"geo":{"longitude":-122.41941550000001,"latitude":37.7749295},"@context":"https://schema.org","@type":"Place","name":"san francisco"}},{"name":"temporalCoverage","rawText":"2018-04-25","textValue":"2018-04-25"}]}]
app.intent('actions.intent.CHECK_AIR_QUALITY',(conv)=>{constattributes=conv.arguments.get('attributes');constlocation=conv.arguments.get('location');consttemporal_coverage=conv.arguments.get('temporalCoverage');Consttime_indicator=conv.arguments.get('timeIndicator')//YourActionlogic.Ifyouneedtouseanyoftheparametervalues,//youshouldcheckfirstthatitisdefined.Arguments.getreturns//undefinedifitcan't find a value for a parameter.});
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eBuilt-in intents allow your Google Action to handle specific user requests, like playing games or getting horoscopes, by mapping them to actions within your Action.\u003c/p\u003e\n"],["\u003cp\u003eYou can integrate built-in intents using Dialogflow (graphically) or the Actions SDK (through code) to specify how your Action responds to these intents.\u003c/p\u003e\n"],["\u003cp\u003eBuilt-in intents often include parameters (like location or time) that you can access in your Action's code to provide a more tailored user experience.\u003c/p\u003e\n"],["\u003cp\u003eTo test your integration, use the Actions simulator or your device to trigger the intent and ensure your Action is invoked and handles the request appropriately.\u003c/p\u003e\n"],["\u003cp\u003eFor optimal user experience, directly address the user's request when a built-in intent triggers your Action and utilize any provided parameters to avoid unnecessary prompts.\u003c/p\u003e\n"]]],[],null,["# Built-in intents (Dialogflow)\n\nA *built-in intent* is a unique identifier that you can specify to tell the\nGoogle Assistant that your Action can fulfill a specific category of user\nrequests. For example, here are some examples of user queries that\nthe Assistant matches to built-in intents:\n\n- **\"Play game\" built-in intent** : *\"Ok Google. Play a memory game\"*\n- **\"Get horoscope\" built-in intent** : *\"Ok Google. Get my horoscope\"*\n\n| **Note:** The 'Play Game' intent is the only built-in intent that is generally available at this time. Other built-in intents mentioned in this documentation are currently in developer preview. You can build and publish Actions that use this feature, but we are still working on fine tuning discovery and ranking.\n|\n| For built-in intents in developer preview, there is no user triggering initially and some\n| intents will not trigger at all. For the time being, you should continue creating\n| [implicit invocations](/assistant/conversational/df-asdk/discovery/implicit) and testing them in addition to\n| registering for built-in intents.\n\nDuring [Action discovery](/assistant/df-asdk/discovery/implicit#action_discovery), the Assistant can use\nmetadata about your Action, including the built-in intents you've specified,\nto recommend your Action to users. To minimize conversational round-trips,\nthe Assistant also attempts to scan parameters from the user queries\nand pass them on to your Action.\n\nTo see the full list of built-in intents that the Assistant supports,\nincluding their parameters and example user queries, see the\n[Built-in intents reference](/assistant/df-asdk/reference/built-in-intents).\n\nIntegrate built-in intents\n--------------------------\n\nDepending on how you are building your Action, there are different ways to\nintegrate built-in intents.\n\n### Dialogflow\n\nIf you are using Dialogflow to create your Action, you can attach a built-in intent\ngraphically from the [Dialogflow console](//console.dialogflow.com).\n\nTo attach a built-in intent with Dialogflow, follow these steps:\n\n1. Open the [Dialogflow console](//console.dialogflow.com), select your agent, then navigate to the **Intents** screen.\n2. Create or select the intent that your agent triggers when it receives a\n specific built-in intent. Open the **Events** section, and click **Add\n Event**.\n\n **Figure 1.** Adding a Dialogflow event in the Dialogflow console.\n3. In the **Events** field, type in the name of a built-in intent event for your\n agent (for example, `actions_intent_PLAY_GAME`).\n\n **Figure 2.** Attaching a built-in intent to your agent in the Dialogflow console.\n4. Click **Save**.\n\n### Actions SDK\n\nIf you are using the Actions SDK to build your Action, you must specify the\nmapping between built-in intents and the Actions in your Action package.\n\nTo attach a built-in intent with Actions SDK, follow these steps:\n\n1. Specify the built-in intent in the name field in your [Action](/assistant/conversational/reference/rest/Shared.Types/Action) definition.\n2. Upload your action package to your Actions project using the `gactions` tool, as described in [Actions SDK overview](/assistant/df-asdk/actions-sdk).\n\nFor example, the following snippet shows how you can add the `CHECK_AIR_QUALITY`\nbuilt-in intent: \n\n {\n \"actions\":[\n {\n \"description\":\"Default Welcome Intent\",\n \"name\":\"MAIN\",\n \"fulfillment\":{\n \"conversationName\":\"conversation_1\"\n },\n \"intent\":{\n \"name\":\"actions.intent.MAIN\"\n }\n },\n {\n \"description\":\"Check Air Quality\",\n \"name\":\"CHECK_AIR_QUALITY\",\n \"fulfillment\":{\n \"conversationName\":\"conversation_1\"\n },\n \"intent\":{\n \"name\":\"actions.intent.CHECK_AIR_QUALITY\"\n }\n }\n ],\n \"conversations\":{\n \"conversation_1\":{\n \"name\":\"conversation_1\",\n \"url\":\"https://example.com/fulfillment\",\n \"fulfillmentApiVersion\":2\n }\n }\n }\n\nHandle built-in intent parameters\n---------------------------------\n\nWhen your Action is invoked through a built-in intent, your fulfillment might\nreceive additional parameters. The intent schema defines the names of the\nparameters and their types as primitive types or [schema.org](//schema.org/)\nentities. To view the schema for Conversational Action built-in intents, see the\n[Built-in intents reference](/assistant/df-asdk/reference/built-in-intents).\n\nParameters for built-in intents are optional. The Assistant handles filling the\nparameters with values if they can be extracted from the user's invocation of\nthe built-in intent.\n\nFor example, the schema of the `actions.intent.CHECK_AIR_QUALITY` built-in\nintent defines four optional parameters:\n\n| Parameter Name | Type |\n|--------------------|--------------------------------------------------------|\n| `attributes` | A string value. |\n| `location` | A [schema.org/Place](//schema.org/Place) object. |\n| `temporalCoverage` | A [schema.org/Duration](//schema.org/Duration) object. |\n| `timeIndicator` | An `EnumeratedDuration` (Google-specific extension). |\n\nThe following code snippet shows an example of the conversation webhook (JSON)\nrequest when a user invokes your Action by saying *\"What's the air quality in\nSan Francisco tomorrow?\"*: \n\n \"inputs\":[\n {\n \"intent\":\"actions.intent.CHECK_AIR_QUALITY\",\n \"rawInputs\":[\n {\n \"inputType\":\"VOICE\",\n \"query\":\"what is the air quality in san francisco tomorrow\"\n }\n ],\n \"arguments\":[\n {\n \"name\":\"location\",\n \"structuredValue\":{\n \"geo\":{\n \"longitude\":-122.41941550000001,\n \"latitude\":37.7749295\n },\n \"@context\":\"https://schema.org\",\n \"@type\":\"Place\",\n \"name\":\"san francisco\"\n }\n },\n {\n \"name\":\"temporalCoverage\",\n \"rawText\":\"2018-04-25\",\n \"textValue\":\"2018-04-25\"\n }\n ]\n }\n ]\n\nIn this example, the parameters take the following values:\n\n- The `location` parameter contains the [`schema.org/Place`](//schema.org/Place) value for \"San Francisco\".\n- The `temporalCoverage` parameter contains the [`schema.org/Duration`](//schema.org/Duration) value for tomorrow's date relative to the time of the invocation.\n- There are no values for the `attributes` and `timeIndicator` parameters because the user's invocation phrase did not include such information.\n\nIf you use the [Actions on Google Client Library for Node.js](/assistant/df-asdk/reference/nodejsv2/overview),\nyou can retrieve the value of the parameters as shown in the following snippet: \n\n app.intent('actions.intent.CHECK_AIR_QUALITY', (conv) =\u003e {\n const attributes = conv.arguments.get('attributes');\n const location = conv.arguments.get('location');\n const temporal_coverage = conv.arguments.get('temporalCoverage');\n Const time_indicator = conv.arguments.get('timeIndicator')\n\n // Your Action logic. If you need to use any of the parameter values,\n // you should check first that it is defined. Arguments.get returns\n // undefined if it can't find a value for a parameter.\n\n });\n\nTest integrations with built-in intents\n---------------------------------------\n\nFollow these steps to test your integration:\n\n1. Open the Actions simulator with your test Action enabled, or open the Assistant on your device.\n2. Speak or type a query associated with that built-in intent. For example, *\"I want to play a game.\"*\n3. From the displayed app selection dialog, find your Action.\n4. Select your app to send an intent to your app.\n\n|------------------------------------------------------------------------------------|-----------------------------------------------------------------|\n| **Figure 3.** The Action selection dialog resulting from a built-in intent phrase. | **Figure 4.** Invoking an Action attached to a built-in intent. |\n\nBest practices for using built-in intents\n-----------------------------------------\n\nYou should follow these best practices when using built-in intents:\n\n- **Map built-in intents to specific actions** : When a specific built-in intent triggers your Action, send the user to the specific intent and functionality in your Action with as little friction as possible. For example, if your Action supports the `PLAY_GAME` built-in intent and receives that intent, you should immediately send the user to the game feature of your Action. Avoid asking the user again if they want to play a game.\n- **Handle built-in intent parameters**: Make sure to use the built-in intent parameter values that the Assistant sends to your fulfillment. Avoid re-prompting the user for those values."]]