Some products and features are in the process of being renamed. Generative playbook and flow features are also being migrated to a single consolidated console. See
the details .
Send feedback
Manage intents with the API
Stay organized with collections
Save and categorize content based on your preferences.
Normally, you create and delete intents using the console.
However, in certain advanced scenarios,
you may find it easier to use the API.
Create an intent
The following examples show how to call the Create
method for the Intent
type.
Go to the Intent API reference
Select a protocol and version for the Intent reference:
Close
REST
Before using any of the request data,
make the following replacements:
PROJECT_ID : your Google Cloud project ID
REGION_ID : your region ID
AGENT_ID : your agent ID
HTTP method and URL:
POST https://REGION_ID -dialogflow.googleapis.com/v3/projects/PROJECT_ID /locations/REGION_ID /agents/AGENT_ID /intents
Request JSON body:
{
"displayName": "My intent display name"
}
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Note:
The following command assumes that you have logged in to
the gcloud
CLI with your user account by running
gcloud init
or
gcloud auth login
, or by using Cloud Shell ,
which automatically logs you into the gcloud
CLI
.
You can check the currently active account by running
gcloud auth list
.
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-user-project: PROJECT_ID " \ -H "Content-Type: application/json; charset=utf-8" \ -d @request.json \ "https://REGION_ID -dialogflow.googleapis.com/v3/projects/PROJECT_ID /locations/REGION_ID /agents/AGENT_ID /intents"
PowerShell (Windows)
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_ID " } Invoke-WebRequest ` -Method POST ` -Headers $headers ` -ContentType: "application/json; charset=utf-8" ` -InFile request.json ` -Uri "https://REGION_ID -dialogflow.googleapis.com/v3/projects/PROJECT_ID /locations/REGION_ID /agents/AGENT_ID /intents" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{
"name": "projects/PROJECT_ID /locations/REGION_ID /agents/AGENT_ID /intents/INTENT_ID ",
"displayName": "My intent display name",
"priority": 500000
}
Update an intent
The
field mask guide
shows how to update individual fields of an intent.
Delete an intent
The following examples show how to call the Delete
method for the Intent
type.
Go to the Intent API reference
Select a protocol and version for the Intent reference:
Close
REST
Before using any of the request data,
make the following replacements:
PROJECT_ID : your Google Cloud project ID
REGION_ID : your region ID
AGENT_ID : your agent ID
INTENT_ID : your intent ID, found in the create response
HTTP method and URL:
DELETE https://REGION_ID -dialogflow.googleapis.com/v3/projects/PROJECT_ID /locations/REGION_ID /agents/AGENT_ID /intents/INTENT_ID
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Note:
The following command assumes that you have logged in to
the gcloud
CLI with your user account by running
gcloud init
or
gcloud auth login
, or by using Cloud Shell ,
which automatically logs you into the gcloud
CLI
.
You can check the currently active account by running
gcloud auth list
.
Execute the following command:
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-user-project: PROJECT_ID " \ "https://REGION_ID -dialogflow.googleapis.com/v3/projects/PROJECT_ID /locations/REGION_ID /agents/AGENT_ID /intents/INTENT_ID "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token $headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_ID " } Invoke-WebRequest ` -Method DELETE ` -Headers $headers ` -Uri "https://REGION_ID -dialogflow.googleapis.com/v3/projects/PROJECT_ID /locations/REGION_ID /agents/AGENT_ID /intents/INTENT_ID " | Select-Object -Expand Content
You should receive a successful status code (2xx) and an empty response.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-02-14 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-14 UTC."],[],[]]