Normally, you create and delete agents using the console. However, in certain advanced scenarios, you may find it easier to use the API.
Create an agent
The following examples show how to call the SetAgent
method for the
Agent
type.
These examples are creating agents,
but the same methods can be used to update agent settings,
like agent edition.
REST
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Google Cloud project ID
HTTP method and URL:
POST https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/agent
Request JSON body:
{ "displayName": "My-display-name", "defaultLanguageCode": "en", "timeZone": "America/New_York" }
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "parent": "projects/PROJECT_ID", "displayName": "My display name", "defaultLanguageCode": "en", "timeZone": "America/New_York", "apiVersion": "API_VERSION_V2" }
Java
To authenticate to Dialogflow, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To authenticate to Dialogflow, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to Dialogflow, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Delete an agent
The following examples show how to call the DeleteAgent
method for the
Agent
type.
REST
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Google Cloud project ID
HTTP method and URL:
DELETE https://dialogflow.googleapis.com/v2/projects/PROJECT_ID/agent
To send your request, expand one of these options:
You should receive a successful status code (2xx) and an empty response.