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 Create
method for the Agent
type.
Select a protocol and version for the Agent reference:
Protocol | V3 | V3beta1 |
---|---|---|
REST | Agent resource | Agent resource |
RPC | Agent interface | Agent interface |
C++ | AgentsClient | Not available |
C# | AgentsClient | Not available |
Go | AgentsClient | Not available |
Java | AgentsClient | AgentsClient |
Node.js | AgentsClient | AgentsClient |
PHP | Not available | Not available |
Python | AgentsClient | AgentsClient |
Ruby | Not available | Not available |
REST
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Google Cloud project ID
- REGION_ID: your region ID
HTTP method and URL:
POST https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents
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:
{ "name": "projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID", "displayName": "My display name", "defaultLanguageCode": "en", "timeZone": "America/New_York", "startFlow": "projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID/flows/00000000-0000-0000-0000-000000000000", "advancedSettings": { "loggingSettings": {} } }
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 Delete
method for the Agent
type.
Select a protocol and version for the Agent reference:
Protocol | V3 | V3beta1 |
---|---|---|
REST | Agent resource | Agent resource |
RPC | Agent interface | Agent interface |
C++ | AgentsClient | Not available |
C# | AgentsClient | Not available |
Go | AgentsClient | Not available |
Java | AgentsClient | AgentsClient |
Node.js | AgentsClient | AgentsClient |
PHP | Not available | Not available |
Python | AgentsClient | AgentsClient |
Ruby | Not available | Not available |
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, found in the agent creation response
HTTP method and URL:
DELETE https://REGION_ID-dialogflow.googleapis.com/v3/projects/PROJECT_ID/locations/REGION_ID/agents/AGENT_ID
To send your request, expand one of these options:
You should receive a successful status code (2xx) and an empty response.