Class AgentsClient (1.0.0)

  AgentsClient 
 ( 
 transport 
 = 
 None 
 , 
 channel 
 = 
 None 
 , 
 credentials 
 = 
 None 
 , 
 client_config 
 = 
 None 
 , 
 client_info 
 = 
 None 
 , 
 client_options 
 = 
 None 
 , 
 ) 
 

Agents are best described as Natural Language Understanding (NLU) modules that transform user requests into actionable data. You can include agents in your app, product, or service to determine user intent and respond to the user in a natural way.

After you create an agent, you can add Intents , Contexts , Entity Types , Webhooks , and so on to manage the flow of a conversation and match user input to predefined intents and actions.

You can create an agent using both Dialogflow Standard Edition and Dialogflow Enterprise Edition. For details, see Dialogflow Editions <https://cloud.google.com/dialogflow/docs/editions> __.

You can save your agent for backup or versioning by exporting the agent by using the ExportAgent method. You can import a saved agent by using the ImportAgent method.

Dialogflow provides several prebuilt agents <https://cloud.google.com/dialogflow/docs/agents-prebuilt> __ for common conversation scenarios such as determining a date and time, converting currency, and so on.

For more information about agents, see the Dialogflow documentation <https://cloud.google.com/dialogflow/docs/agents-overview> __.

Methods

AgentsClient

  AgentsClient 
 ( 
 transport 
 = 
 None 
 , 
 channel 
 = 
 None 
 , 
 credentials 
 = 
 None 
 , 
 client_config 
 = 
 None 
 , 
 client_info 
 = 
 None 
 , 
 client_options 
 = 
 None 
 , 
 ) 
 

Constructor.

Parameters
Name
Description
channel
grpc.Channel

DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials ; providing both will raise an exception.

credentials
google.auth.credentials.Credentials

The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport ; doing so will raise an exception.

client_config
dict

DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

client_info
google.api_core.gapic_v1.client_info.ClientInfo

The client info used to send a user-agent string along with API requests. If None , then default info will be used. Generally, you only need to set this if you're developing your own client library.

client_options
Union[dict, google.api_core.client_options.ClientOptions]

Client options used to set user options on the client. API Endpoint should be set through client_options.

delete_agent

  delete_agent 
 ( 
 parent 
 , 
 retry 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 timeout 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 metadata 
 = 
 None 
 ) 
 

Deletes the specified agent.

.. rubric:: Example

import dialogflow_v2beta1

client = dialogflow_v2beta1.AgentsClient()

parent = client.project_path('[PROJECT]')

client.delete_agent(parent)

Parameters
Name
Description
parent
str

Required. The project that the agent to delete is associated with. Format: projects/ .

retry
Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout
Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata
Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
Type
Description
google.api_core.exceptions.GoogleAPICallError
If the request failed for any reason.
google.api_core.exceptions.RetryError
If the request failed due to a retryable error and retry attempts failed.
ValueError
If the parameters are invalid.

export_agent

  export_agent 
 ( 
 parent 
 , 
 agent_uri 
 = 
 None 
 , 
 retry 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 timeout 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 metadata 
 = 
 None 
 ) 
 

Exports the specified agent to a ZIP file.

Operation <response: ExportAgentResponse >

.. rubric:: Example

import dialogflow_v2beta1

client = dialogflow_v2beta1.AgentsClient()

parent = client.project_path('[PROJECT]')

response = client.export_agent(parent)

def callback(operation_future): ... # Handle result. ... result = operation_future.result()

response.add_done_callback(callback)

Handle metadata.

metadata = response.metadata()

Parameters
Name
Description
parent
str

Required. The project that the agent to export is associated with. Format: projects/ .

agent_uri
str

Optional. The Google Cloud Storage https://cloud.google.com/storage/docs/ __ URI to export the agent to. The format of this URI must be gs:// . If left unspecified, the serialized agent is returned inline.

retry
Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout
Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata
Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
Type
Description
google.api_core.exceptions.GoogleAPICallError
If the request failed for any reason.
google.api_core.exceptions.RetryError
If the request failed due to a retryable error and retry attempts failed.
ValueError
If the parameters are invalid.
  from_service_account_file 
 ( 
 filename 
 , 
 * 
 args 
 , 
 ** 
 kwargs 
 ) 
 

Creates an instance of this client using the provided credentials file.

Parameter
Name
Description
filename
str

The path to the service account private key json file.

Returns
Type
Description
dialogflow_v2beta1.AgentsClient
The constructed client.
  from_service_account_json 
 ( 
 filename 
 , 
 * 
 args 
 , 
 ** 
 kwargs 
 ) 
 

Creates an instance of this client using the provided credentials file.

Parameter
Name
Description
filename
str

The path to the service account private key json file.

Returns
Type
Description
dialogflow_v2beta1.AgentsClient
The constructed client.

get_agent

  get_agent 
 ( 
 parent 
 , 
 retry 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 timeout 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 metadata 
 = 
 None 
 ) 
 

Retrieves the specified agent.

.. rubric:: Example

import dialogflow_v2beta1

client = dialogflow_v2beta1.AgentsClient()

parent = client.project_path('[PROJECT]')

response = client.get_agent(parent)

Parameters
Name
Description
parent
str

Required. The project that the agent to fetch is associated with. Format: projects/ .

retry
Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout
Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata
Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
Type
Description
google.api_core.exceptions.GoogleAPICallError
If the request failed for any reason.
google.api_core.exceptions.RetryError
If the request failed due to a retryable error and retry attempts failed.
ValueError
If the parameters are invalid.

get_validation_result

  get_validation_result 
 ( 
 parent 
 = 
 None 
 , 
 language_code 
 = 
 None 
 , 
 retry 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 timeout 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 metadata 
 = 
 None 
 ) 
 

Gets agent validation result. Agent validation is performed during training time and is updated automatically when training is completed.

.. rubric:: Example

import dialogflow_v2beta1

client = dialogflow_v2beta1.AgentsClient()

response = client.get_validation_result()

Parameters
Name
Description
parent
str

Required. The project that the agent is associated with. Format: projects/ .

language_code
str

Optional. The language for which you want a validation result. If not specified, the agent's default language is used. Many languages https://cloud.google.com/dialogflow/docs/reference/language __ are supported. Note: languages must be enabled in the agent before they can be used.

retry
Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout
Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata
Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
Type
Description
google.api_core.exceptions.GoogleAPICallError
If the request failed for any reason.
google.api_core.exceptions.RetryError
If the request failed due to a retryable error and retry attempts failed.
ValueError
If the parameters are invalid.

import_agent

  import_agent 
 ( 
 parent 
 , 
 agent_uri 
 = 
 None 
 , 
 agent_content 
 = 
 None 
 , 
 retry 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 timeout 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 metadata 
 = 
 None 
 ) 
 

Imports the specified agent from a ZIP file.

Uploads new intents and entity types without deleting the existing ones. Intents and entity types with the same name are replaced with the new versions from ImportAgentRequest.

Operation <response: google.protobuf.Empty >

.. rubric:: Example

import dialogflow_v2beta1

client = dialogflow_v2beta1.AgentsClient()

parent = client.project_path('[PROJECT]')

response = client.import_agent(parent)

def callback(operation_future): ... # Handle result. ... result = operation_future.result()

response.add_done_callback(callback)

Handle metadata.

metadata = response.metadata()

Parameters
Name
Description
parent
str

Required. The project that the agent to import is associated with. Format: projects/ .

agent_uri
str

The URI to a Google Cloud Storage file containing the agent to import. Note: The URI must start with "gs://".

agent_content
bytes

Zip compressed raw byte content for agent.

retry
Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout
Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata
Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
Type
Description
google.api_core.exceptions.GoogleAPICallError
If the request failed for any reason.
google.api_core.exceptions.RetryError
If the request failed due to a retryable error and retry attempts failed.
ValueError
If the parameters are invalid.

project_path

  project_path 
 ( 
 project 
 ) 
 

Return a fully-qualified project string.

restore_agent

  restore_agent 
 ( 
 parent 
 , 
 agent_uri 
 = 
 None 
 , 
 agent_content 
 = 
 None 
 , 
 retry 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 timeout 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 metadata 
 = 
 None 
 ) 
 

Restores the specified agent from a ZIP file.

Replaces the current agent version with a new one. All the intents and entity types in the older version are deleted.

Operation <response: google.protobuf.Empty >

.. rubric:: Example

import dialogflow_v2beta1

client = dialogflow_v2beta1.AgentsClient()

parent = client.project_path('[PROJECT]')

response = client.restore_agent(parent)

def callback(operation_future): ... # Handle result. ... result = operation_future.result()

response.add_done_callback(callback)

Handle metadata.

metadata = response.metadata()

Parameters
Name
Description
parent
str

Required. The project that the agent to restore is associated with. Format: projects/ .

agent_uri
str

The URI to a Google Cloud Storage file containing the agent to restore. Note: The URI must start with "gs://".

agent_content
bytes

Zip compressed raw byte content for agent.

retry
Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout
Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata
Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
Type
Description
google.api_core.exceptions.GoogleAPICallError
If the request failed for any reason.
google.api_core.exceptions.RetryError
If the request failed due to a retryable error and retry attempts failed.
ValueError
If the parameters are invalid.

search_agents

  search_agents 
 ( 
 parent 
 , 
 page_size 
 = 
 None 
 , 
 retry 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 timeout 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 metadata 
 = 
 None 
 ) 
 

Returns the list of agents.

Since there is at most one conversational agent per project, this method is useful primarily for listing all agents across projects the caller has access to. One can achieve that with a wildcard project collection id "-". Refer to List Sub-Collections <https://cloud.google.com/apis/design/design_patterns#list_sub-collections> __.

.. rubric:: Example

import dialogflow_v2beta1

client = dialogflow_v2beta1.AgentsClient()

parent = client.project_path('[PROJECT]')

Iterate over all results

for element in client.search_agents(parent): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.search_agents(parent).pages: ... for element in page: ... # process element ... pass

Parameters
Name
Description
parent
str

Required. The project to list agents from. Format: projects/<Project ID or '-'> .

page_size
int

The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

retry
Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout
Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata
Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
Type
Description
google.api_core.exceptions.GoogleAPICallError
If the request failed for any reason.
google.api_core.exceptions.RetryError
If the request failed due to a retryable error and retry attempts failed.
ValueError
If the parameters are invalid.

set_agent

  set_agent 
 ( 
 agent 
 , 
 update_mask 
 = 
 None 
 , 
 retry 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 timeout 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 metadata 
 = 
 None 
 ) 
 

Creates/updates the specified agent.

.. rubric:: Example

import dialogflow_v2beta1

client = dialogflow_v2beta1.AgentsClient()

TODO: Initialize agent :

agent = {}

response = client.set_agent(agent)

Parameters
Name
Description
agent
Union[dict, Agent ]

Required. The agent to update. If a dict is provided, it must be of the same form as the protobuf message Agent

update_mask
Union[dict, FieldMask ]

Optional. The mask to control which fields get updated. If a dict is provided, it must be of the same form as the protobuf message FieldMask

retry
Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout
Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata
Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
Type
Description
google.api_core.exceptions.GoogleAPICallError
If the request failed for any reason.
google.api_core.exceptions.RetryError
If the request failed due to a retryable error and retry attempts failed.
ValueError
If the parameters are invalid.

train_agent

  train_agent 
 ( 
 parent 
 , 
 retry 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 timeout 
 = 
< _MethodDefault 
 . 
 _DEFAULT_VALUE 
 : 
< object 
 object 
>> , 
 metadata 
 = 
 None 
 ) 
 

Trains the specified agent.

Operation <response: google.protobuf.Empty >

.. rubric:: Example

import dialogflow_v2beta1

client = dialogflow_v2beta1.AgentsClient()

parent = client.project_path('[PROJECT]')

response = client.train_agent(parent)

def callback(operation_future): ... # Handle result. ... result = operation_future.result()

response.add_done_callback(callback)

Handle metadata.

metadata = response.metadata()

Parameters
Name
Description
parent
str

Required. The project that the agent to train is associated with. Format: projects/ .

retry
Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout
Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata
Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
Type
Description
google.api_core.exceptions.GoogleAPICallError
If the request failed for any reason.
google.api_core.exceptions.RetryError
If the request failed due to a retryable error and retry attempts failed.
ValueError
If the parameters are invalid.
Create a Mobile Website
View Site in Mobile | Classic
Share by: