Beberapa produk dan fitur sedang dalam proses penggantian nama. Fitur playbook dan alur generatif juga dimigrasikan ke satu konsol gabungan. Lihat detailnya.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Biasanya, Anda membuat dan menghapus intent menggunakan konsol.
Namun, dalam skenario lanjutan tertentu, Anda mungkin merasa lebih mudah menggunakan API.
Membuat intent
Contoh berikut menunjukkan cara memanggil metode Create untuk jenis Intent.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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"]]