Alcuni prodotti e funzionalità sono in fase di rinominazione. Anche le funzionalità di playbook e flusso generativi sono in fase di migrazione a un'unica console consolidata. Consulta i dettagli.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
In genere, gli intent vengono creati ed eliminati utilizzando la console.
Tuttavia, in alcuni scenari avanzati,
potresti trovare più semplice utilizzare l'API.
Creare un intent
Gli esempi seguenti mostrano come chiamare il metodo Create per il tipo Intent.
Seleziona un protocollo e una versione per il riferimento all'intent:
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eIntents can be created and deleted via the API for advanced scenarios, offering an alternative to the console.\u003c/p\u003e\n"],["\u003cp\u003eThe API reference provides protocol-specific (REST, RPC) and language-specific (C++, C#, Go, Java, Node.js, Python) guidance for creating and deleting intents.\u003c/p\u003e\n"],["\u003cp\u003eCreating an intent using the REST API involves a POST request to a specified URL, with a JSON body containing the intent's display name.\u003c/p\u003e\n"],["\u003cp\u003eDeleting an intent using the REST API involves a DELETE request to a specific URL that includes the \u003ccode\u003eINTENT_ID\u003c/code\u003e, returning a successful status code and an empty response.\u003c/p\u003e\n"],["\u003cp\u003eUpdating specific fields of an intent can be done by using the field mask guide provided in the content.\u003c/p\u003e\n"]]],[],null,["# Manage intents with the API\n\nNormally, you create and delete intents using the console.\nHowever, in certain advanced scenarios,\nyou may find it easier to use the API.\n\nCreate an intent\n----------------\n\nThe following examples show how to call the `Create` method for the `Intent` type.\n\n\nGo to the Intent API reference \n**Select a protocol and version for the Intent reference:**\n\nClose\n\n\u003cbr /\u003e\n\n### REST\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your Google Cloud project ID\n- \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e: your [region ID](/dialogflow/cx/docs/concept/region)\n- \u003cvar translate=\"no\"\u003eAGENT_ID\u003c/var\u003e: your agent ID\n\n\nHTTP method and URL:\n\n```\nPOST https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents\n```\n\n\nRequest JSON body:\n\n```\n{\n \"displayName\": \"My intent display name\"\n}\n```\n\nTo send your request, expand one of these options:\n\n#### curl (Linux, macOS, or Cloud Shell)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\ncurl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"x-goog-user-project: PROJECT_ID\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @request.json \\\n \"https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents\"\n```\n\n#### PowerShell (Windows)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\"; \"x-goog-user-project\" = \"PROJECT_ID\" }\n\nInvoke-WebRequest `\n -Method POST `\n -Headers $headers `\n -ContentType: \"application/json; charset=utf-8\" `\n -InFile request.json `\n -Uri \"https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents\" | Select-Object -Expand Content\n```\n\nYou should receive a JSON response similar to the following:\n\n```\n{\n \"name\": \"projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID\",\n \"displayName\": \"My intent display name\",\n \"priority\": 500000\n}\n```\n\n\u003cbr /\u003e\n\nUpdate an intent\n----------------\n\nThe\n[field mask guide](/dialogflow/cx/docs/how/field-mask)\nshows how to update individual fields of an intent.\n\nDelete an intent\n----------------\n\nThe following examples show how to call the `Delete` method for the `Intent` type.\n\n\nGo to the Intent API reference \n**Select a protocol and version for the Intent reference:**\n\nClose\n\n\u003cbr /\u003e\n\n### REST\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your Google Cloud project ID\n- \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e: your [region ID](/dialogflow/cx/docs/concept/region)\n- \u003cvar translate=\"no\"\u003eAGENT_ID\u003c/var\u003e: your agent ID\n- \u003cvar translate=\"no\"\u003eINTENT_ID\u003c/var\u003e: your intent ID, found in the create response\n\n\nHTTP method and URL:\n\n```\nDELETE https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID\n```\n\nTo send your request, expand one of these options:\n\n#### curl (Linux, macOS, or Cloud Shell)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nExecute the following command:\n\n```\ncurl -X DELETE \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"x-goog-user-project: PROJECT_ID\" \\\n \"https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID\"\n```\n\n#### PowerShell (Windows)\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nExecute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\"; \"x-goog-user-project\" = \"PROJECT_ID\" }\n\nInvoke-WebRequest `\n -Method DELETE `\n -Headers $headers `\n -Uri \"https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/intents/INTENT_ID\" | Select-Object -Expand Content\n```\n\nYou should receive a successful status code (2xx) and an empty response.\n\n\u003cbr /\u003e"]]