IntentsClient

IntentsClient

An intent represents a mapping between input from a user and an action to be taken by your application. When you pass user input to the DetectIntent (or StreamingDetectIntent) method, the Dialogflow API analyzes the input and searches for a matching intent. If no match is found, the Dialogflow API returns a fallback intent (is_fallback = true).

You can provide additional information for the Dialogflow API to use to match user input to an intent by adding the following to your intent.

  • Contexts - provide additional context for intent analysis. For example, if an intent is related to an object in your application that plays music, you can provide a context to determine when to match the intent if the user input is "turn it off". You can include a context that matches the intent when there is previous user input of "play music", and not when there is previous user input of "turn on the light".

  • Events - allow for matching an intent by using an event name instead of user input. Your application can provide an event name and related parameters to the Dialogflow API to match an intent. For example, when your application starts, you can send a welcome event with a user name parameter to the Dialogflow API to match an intent with a personalized welcome message for the user.

  • Training phrases - provide examples of user input to train the Dialogflow API agent to better match intents.

For more information about intents, see the Dialogflow documentation.

Constructor

new IntentsClient(optionsopt)

Construct an instance of IntentsClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

(static) port

The port for this API service.

(static) scopes

The scopes needed to make gRPC calls for every method defined in this service.

(static) servicePath

The DNS address for this API service.

Methods

agentPath(project) → {string}

Return a fully-qualified agent resource name string.

Parameters:
Name Type Description
project string

batchDeleteIntents(request, optionsopt) → {Promise}

Deletes intents in the specified agent.

Operation <response: google.protobuf.Empty>

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The name of the agent to delete all entities types for. Format: projects/<Project ID>/agent.

intents Array.<number>

Required. The collection of intents to delete. Only intent name must be filled in.

options object <optional>

Call options. See CallOptions for more details.

batchUpdateIntents(request, optionsopt) → {Promise}

Updates/Creates multiple intents in the specified agent.

Operation <response: BatchUpdateIntentsResponse>

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The name of the agent to update or create intents in. Format: projects/<Project ID>/agent.

intentBatchUri string

The URI to a Google Cloud Storage file containing intents to update or create. The file format can either be a serialized proto (of IntentBatch type) or JSON object. Note: The URI must start with "gs://".

intentBatchInline google.cloud.dialogflow.v2.IntentBatch

The collection of intents to update or create.

languageCode string <optional>

Optional. The language used to access language-specific data. If not specified, the agent's default language is used. For more information, see Multilingual intent and entity data.

updateMask google.protobuf.FieldMask <optional>

Optional. The mask to control which fields get updated.

intentView google.cloud.dialogflow.v2.IntentView <optional>

Optional. The resource view to apply to the returned intent.

options object <optional>

Call options. See CallOptions for more details.

close()

Terminate the GRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

createIntent(request, optionsopt) → {Promise}

Creates an intent in the specified agent.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The agent to create a intent for. Format: projects/<Project ID>/agent.

intent google.cloud.dialogflow.v2.Intent

Required. The intent to create.

languageCode string <optional>

Optional. The language used to access language-specific data. If not specified, the agent's default language is used. For more information, see Multilingual intent and entity data.

intentView google.cloud.dialogflow.v2.IntentView <optional>

Optional. The resource view to apply to the returned intent.

options object <optional>

Call options. See CallOptions for more details.

deleteIntent(request, optionsopt) → {Promise}

Deletes the specified intent and its direct or indirect followup intents.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the intent to delete. If this intent has direct or indirect followup intents, we also delete them. Format: projects/<Project ID>/agent/intents/<Intent ID>.

options object <optional>

Call options. See CallOptions for more details.

entityTypePath(project, entity_type) → {string}

Return a fully-qualified entityType resource name string.

Parameters:
Name Type Description
project string
entity_type string

environmentPath(project, environment) → {string}

Return a fully-qualified environment resource name string.

Parameters:
Name Type Description
project string
environment string

getIntent(request, optionsopt) → {Promise}

Retrieves the specified intent.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

Required. The name of the intent. Format: projects/<Project ID>/agent/intents/<Intent ID>.

languageCode string <optional>

Optional. The language used to access language-specific data. If not specified, the agent's default language is used. For more information, see Multilingual intent and entity data.

intentView google.cloud.dialogflow.v2.IntentView <optional>

Optional. The resource view to apply to the returned intent.

options object <optional>

Call options. See CallOptions for more details.

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

intentPath(project, intent) → {string}

Return a fully-qualified intent resource name string.

Parameters:
Name Type Description
project string
intent string

listIntents(request, optionsopt) → {Promise}

Returns the list of all intents in the specified agent.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The agent to list all intents from. Format: projects/<Project ID>/agent.

languageCode string <optional>

Optional. The language used to access language-specific data. If not specified, the agent's default language is used. For more information, see Multilingual intent and entity data.

intentView google.cloud.dialogflow.v2.IntentView <optional>

Optional. The resource view to apply to the returned intent.

pageSize number <optional>

Optional. The maximum number of items to return in a single page. By default 100 and at most 1000.

pageToken string <optional>

Optional. The next_page_token value returned from a previous list request.

options object <optional>

Call options. See CallOptions for more details.

listIntentsAsync(request, optionsopt) → {Object}

Equivalent to listIntents, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The agent to list all intents from. Format: projects/<Project ID>/agent.

languageCode string <optional>

Optional. The language used to access language-specific data. If not specified, the agent's default language is used. For more information, see Multilingual intent and entity data.

intentView google.cloud.dialogflow.v2.IntentView <optional>

Optional. The resource view to apply to the returned intent.

pageSize number <optional>

Optional. The maximum number of items to return in a single page. By default 100 and at most 1000.

pageToken string <optional>

Optional. The next_page_token value returned from a previous list request.

options object <optional>

Call options. See CallOptions for more details.

listIntentsStream(request, optionsopt) → {Stream}

Equivalent to listIntents, but returns a NodeJS Stream object.

This fetches the paged responses for listIntents continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Required. The agent to list all intents from. Format: projects/<Project ID>/agent.

languageCode string <optional>

Optional. The language used to access language-specific data. If not specified, the agent's default language is used. For more information, see Multilingual intent and entity data.

intentView google.cloud.dialogflow.v2.IntentView <optional>

Optional. The resource view to apply to the returned intent.

pageSize number <optional>

Optional. The maximum number of items to return in a single page. By default 100 and at most 1000.

pageToken string <optional>

Optional. The next_page_token value returned from a previous list request.

options object <optional>

Call options. See CallOptions for more details.

See:

matchContextFromProjectAgentEnvironmentUserSessionContextName(projectAgentEnvironmentUserSessionContextName) → {string}

Parse the context from ProjectAgentEnvironmentUserSessionContext resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionContextName string

A fully-qualified path representing project_agent_environment_user_session_context resource.

matchContextFromProjectAgentSessionContextName(projectAgentSessionContextName) → {string}

Parse the context from ProjectAgentSessionContext resource.

Parameters:
Name Type Description
projectAgentSessionContextName string

A fully-qualified path representing project_agent_session_context resource.

matchEntityTypeFromEntityTypeName(entityTypeName) → {string}

Parse the entity_type from EntityType resource.

Parameters:
Name Type Description
entityTypeName string

A fully-qualified path representing EntityType resource.

matchEntityTypeFromProjectAgentEnvironmentUserSessionEntityTypeName(projectAgentEnvironmentUserSessionEntityTypeName) → {string}

Parse the entity_type from ProjectAgentEnvironmentUserSessionEntityType resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionEntityTypeName string

A fully-qualified path representing project_agent_environment_user_session_entity_type resource.

matchEntityTypeFromProjectAgentSessionEntityTypeName(projectAgentSessionEntityTypeName) → {string}

Parse the entity_type from ProjectAgentSessionEntityType resource.

Parameters:
Name Type Description
projectAgentSessionEntityTypeName string

A fully-qualified path representing project_agent_session_entity_type resource.

matchEnvironmentFromEnvironmentName(environmentName) → {string}

Parse the environment from Environment resource.

Parameters:
Name Type Description
environmentName string

A fully-qualified path representing Environment resource.

matchEnvironmentFromProjectAgentEnvironmentUserSessionContextName(projectAgentEnvironmentUserSessionContextName) → {string}

Parse the environment from ProjectAgentEnvironmentUserSessionContext resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionContextName string

A fully-qualified path representing project_agent_environment_user_session_context resource.

matchEnvironmentFromProjectAgentEnvironmentUserSessionEntityTypeName(projectAgentEnvironmentUserSessionEntityTypeName) → {string}

Parse the environment from ProjectAgentEnvironmentUserSessionEntityType resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionEntityTypeName string

A fully-qualified path representing project_agent_environment_user_session_entity_type resource.

matchIntentFromIntentName(intentName) → {string}

Parse the intent from Intent resource.

Parameters:
Name Type Description
intentName string

A fully-qualified path representing Intent resource.

matchProjectFromAgentName(agentName) → {string}

Parse the project from Agent resource.

Parameters:
Name Type Description
agentName string

A fully-qualified path representing Agent resource.

matchProjectFromEntityTypeName(entityTypeName) → {string}

Parse the project from EntityType resource.

Parameters:
Name Type Description
entityTypeName string

A fully-qualified path representing EntityType resource.

matchProjectFromEnvironmentName(environmentName) → {string}

Parse the project from Environment resource.

Parameters:
Name Type Description
environmentName string

A fully-qualified path representing Environment resource.

matchProjectFromIntentName(intentName) → {string}

Parse the project from Intent resource.

Parameters:
Name Type Description
intentName string

A fully-qualified path representing Intent resource.

matchProjectFromProjectAgentEnvironmentUserSessionContextName(projectAgentEnvironmentUserSessionContextName) → {string}

Parse the project from ProjectAgentEnvironmentUserSessionContext resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionContextName string

A fully-qualified path representing project_agent_environment_user_session_context resource.

matchProjectFromProjectAgentEnvironmentUserSessionEntityTypeName(projectAgentEnvironmentUserSessionEntityTypeName) → {string}

Parse the project from ProjectAgentEnvironmentUserSessionEntityType resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionEntityTypeName string

A fully-qualified path representing project_agent_environment_user_session_entity_type resource.

matchProjectFromProjectAgentSessionContextName(projectAgentSessionContextName) → {string}

Parse the project from ProjectAgentSessionContext resource.

Parameters:
Name Type Description
projectAgentSessionContextName string

A fully-qualified path representing project_agent_session_context resource.

matchProjectFromProjectAgentSessionEntityTypeName(projectAgentSessionEntityTypeName) → {string}

Parse the project from ProjectAgentSessionEntityType resource.

Parameters:
Name Type Description
projectAgentSessionEntityTypeName string

A fully-qualified path representing project_agent_session_entity_type resource.

matchProjectFromProjectName(projectName) → {string}

Parse the project from Project resource.

Parameters:
Name Type Description
projectName string

A fully-qualified path representing Project resource.

matchSessionFromProjectAgentEnvironmentUserSessionContextName(projectAgentEnvironmentUserSessionContextName) → {string}

Parse the session from ProjectAgentEnvironmentUserSessionContext resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionContextName string

A fully-qualified path representing project_agent_environment_user_session_context resource.

matchSessionFromProjectAgentEnvironmentUserSessionEntityTypeName(projectAgentEnvironmentUserSessionEntityTypeName) → {string}

Parse the session from ProjectAgentEnvironmentUserSessionEntityType resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionEntityTypeName string

A fully-qualified path representing project_agent_environment_user_session_entity_type resource.

matchSessionFromProjectAgentSessionContextName(projectAgentSessionContextName) → {string}

Parse the session from ProjectAgentSessionContext resource.

Parameters:
Name Type Description
projectAgentSessionContextName string

A fully-qualified path representing project_agent_session_context resource.

matchSessionFromProjectAgentSessionEntityTypeName(projectAgentSessionEntityTypeName) → {string}

Parse the session from ProjectAgentSessionEntityType resource.

Parameters:
Name Type Description
projectAgentSessionEntityTypeName string

A fully-qualified path representing project_agent_session_entity_type resource.

matchUserFromProjectAgentEnvironmentUserSessionContextName(projectAgentEnvironmentUserSessionContextName) → {string}

Parse the user from ProjectAgentEnvironmentUserSessionContext resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionContextName string

A fully-qualified path representing project_agent_environment_user_session_context resource.

matchUserFromProjectAgentEnvironmentUserSessionEntityTypeName(projectAgentEnvironmentUserSessionEntityTypeName) → {string}

Parse the user from ProjectAgentEnvironmentUserSessionEntityType resource.

Parameters:
Name Type Description
projectAgentEnvironmentUserSessionEntityTypeName string

A fully-qualified path representing project_agent_environment_user_session_entity_type resource.

projectAgentEnvironmentUserSessionContextPath(project, environment, user, session, context) → {string}

Return a fully-qualified projectAgentEnvironmentUserSessionContext resource name string.

Parameters:
Name Type Description
project string
environment string
user string
session string
context string

projectAgentEnvironmentUserSessionEntityTypePath(project, environment, user, session, entity_type) → {string}

Return a fully-qualified projectAgentEnvironmentUserSessionEntityType resource name string.

Parameters:
Name Type Description
project string
environment string
user string
session string
entity_type string

projectAgentSessionContextPath(project, session, context) → {string}

Return a fully-qualified projectAgentSessionContext resource name string.

Parameters:
Name Type Description
project string
session string
context string

projectAgentSessionEntityTypePath(project, session, entity_type) → {string}

Return a fully-qualified projectAgentSessionEntityType resource name string.

Parameters:
Name Type Description
project string
session string
entity_type string

projectPath(project) → {string}

Return a fully-qualified project resource name string.

Parameters:
Name Type Description
project string

updateIntent(request, optionsopt) → {Promise}

Updates the specified intent.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
intent google.cloud.dialogflow.v2.Intent

Required. The intent to update.

languageCode string <optional>

Optional. The language used to access language-specific data. If not specified, the agent's default language is used. For more information, see Multilingual intent and entity data.

updateMask google.protobuf.FieldMask <optional>

Optional. The mask to control which fields get updated.

intentView google.cloud.dialogflow.v2.IntentView <optional>

Optional. The resource view to apply to the returned intent.

options object <optional>

Call options. See CallOptions for more details.