v2beta1. EntityTypesClient
Entities are extracted from user input and represent parameters that are meaningful to your application. For example, a date range, a proper name such as a geographic location or landmark, and so on. Entities represent actionable data for your application.
When you define an entity, you can also include synonyms that all map to that entity. For example, "soft drink", "soda", "pop", and so on.
There are three types of entities:
-
System - entities that are defined by the Dialogflow API for common data types such as date, time, currency, and so on. A system entity is represented by the
EntityType
type. -
Developer - entities that are defined by you that represent actionable data that is meaningful to your application. For example, you could define a
pizza.sauce
entity for red or white pizza sauce, apizza.cheese
entity for the different types of cheese on a pizza, apizza.topping
entity for different toppings, and so on. A developer entity is represented by theEntityType
type. -
User - entities that are built for an individual user such as favorites, preferences, playlists, and so on. A user entity is represented by the SessionEntityType type.
For more information about entity types, see the Dialogflow documentation.
Constructor
EntityTypesClient
new EntityTypesClient(options)
Construct an instance of EntityTypesClient.
Parameter |
|||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Optional object The configuration object. See the subsequent parameters for more details. Values in
|
Properties
port
The port for this API service.
scopes
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
The DNS address for this API service.
Methods
batchCreateEntities
batchCreateEntities(request, options, callback) returns Promise
Creates multiple new entities in the specified entity type (extends the existing collection of entries).
Operation <response: google.protobuf.Empty>
Parameter |
|||||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is a gax.Operation object. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const formattedParent = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
const entities = [];
const request = {
parent: formattedParent,
entities: entities,
};
// Handle the operation using the promise pattern.
client.batchCreateEntities(request)
.then(responses => {
const [operation, initialApiResponse] = responses;
// Operation#promise starts polling for the completion of the LRO.
return operation.promise();
})
.then(responses => {
const result = responses[0];
const metadata = responses[1];
const finalApiResponse = responses[2];
})
.catch(err => {
console.error(err);
});
const formattedParent = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
const entities = [];
const request = {
parent: formattedParent,
entities: entities,
};
// Handle the operation using the event emitter pattern.
client.batchCreateEntities(request)
.then(responses => {
const [operation, initialApiResponse] = responses;
// Adding a listener for the "complete" event starts polling for the
// completion of the operation.
operation.on('complete', (result, metadata, finalApiResponse) => {
// doSomethingWith(result);
});
// Adding a listener for the "progress" event causes the callback to be
// called on any change in metadata when the operation is polled.
operation.on('progress', (metadata, apiResponse) => {
// doSomethingWith(metadata)
});
// Adding a listener for the "error" event handles any errors found during polling.
operation.on('error', err => {
// throw(err);
});
})
.catch(err => {
console.error(err);
});
const formattedParent = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
const entities = [];
const request = {
parent: formattedParent,
entities: entities,
};
// Handle the operation using the await pattern.
const [operation] = await client.batchCreateEntities(request);
const [response] = await operation.promise();
batchDeleteEntities
batchDeleteEntities(request, options, callback) returns Promise
Deletes entities in the specified entity type.
Operation <response: google.protobuf.Empty, metadata: google.protobuf.Struct>
Parameter |
|||||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is a gax.Operation object. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const formattedParent = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
const entityValues = [];
const request = {
parent: formattedParent,
entityValues: entityValues,
};
// Handle the operation using the promise pattern.
client.batchDeleteEntities(request)
.then(responses => {
const [operation, initialApiResponse] = responses;
// Operation#promise starts polling for the completion of the LRO.
return operation.promise();
})
.then(responses => {
const result = responses[0];
const metadata = responses[1];
const finalApiResponse = responses[2];
})
.catch(err => {
console.error(err);
});
const formattedParent = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
const entityValues = [];
const request = {
parent: formattedParent,
entityValues: entityValues,
};
// Handle the operation using the event emitter pattern.
client.batchDeleteEntities(request)
.then(responses => {
const [operation, initialApiResponse] = responses;
// Adding a listener for the "complete" event starts polling for the
// completion of the operation.
operation.on('complete', (result, metadata, finalApiResponse) => {
// doSomethingWith(result);
});
// Adding a listener for the "progress" event causes the callback to be
// called on any change in metadata when the operation is polled.
operation.on('progress', (metadata, apiResponse) => {
// doSomethingWith(metadata)
});
// Adding a listener for the "error" event handles any errors found during polling.
operation.on('error', err => {
// throw(err);
});
})
.catch(err => {
console.error(err);
});
const formattedParent = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
const entityValues = [];
const request = {
parent: formattedParent,
entityValues: entityValues,
};
// Handle the operation using the await pattern.
const [operation] = await client.batchDeleteEntities(request);
const [response] = await operation.promise();
batchDeleteEntityTypes
batchDeleteEntityTypes(request, options, callback) returns Promise
Deletes entity types in the specified agent.
Operation <response: google.protobuf.Empty, metadata: google.protobuf.Struct>
Parameter |
|||||||
---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is a gax.Operation object. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const formattedParent = client.projectAgentPath('[PROJECT]');
const entityTypeNames = [];
const request = {
parent: formattedParent,
entityTypeNames: entityTypeNames,
};
// Handle the operation using the promise pattern.
client.batchDeleteEntityTypes(request)
.then(responses => {
const [operation, initialApiResponse] = responses;
// Operation#promise starts polling for the completion of the LRO.
return operation.promise();
})
.then(responses => {
const result = responses[0];
const metadata = responses[1];
const finalApiResponse = responses[2];
})
.catch(err => {
console.error(err);
});
const formattedParent = client.projectAgentPath('[PROJECT]');
const entityTypeNames = [];
const request = {
parent: formattedParent,
entityTypeNames: entityTypeNames,
};
// Handle the operation using the event emitter pattern.
client.batchDeleteEntityTypes(request)
.then(responses => {
const [operation, initialApiResponse] = responses;
// Adding a listener for the "complete" event starts polling for the
// completion of the operation.
operation.on('complete', (result, metadata, finalApiResponse) => {
// doSomethingWith(result);
});
// Adding a listener for the "progress" event causes the callback to be
// called on any change in metadata when the operation is polled.
operation.on('progress', (metadata, apiResponse) => {
// doSomethingWith(metadata)
});
// Adding a listener for the "error" event handles any errors found during polling.
operation.on('error', err => {
// throw(err);
});
})
.catch(err => {
console.error(err);
});
const formattedParent = client.projectAgentPath('[PROJECT]');
const entityTypeNames = [];
const request = {
parent: formattedParent,
entityTypeNames: entityTypeNames,
};
// Handle the operation using the await pattern.
const [operation] = await client.batchDeleteEntityTypes(request);
const [response] = await operation.promise();
batchUpdateEntities
batchUpdateEntities(request, options, callback) returns Promise
Updates entities in the specified entity type (replaces the existing collection of entries).
Operation <response: google.protobuf.Empty, metadata: google.protobuf.Struct>
Parameter |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is a gax.Operation object. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const formattedParent = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
const entities = [];
const request = {
parent: formattedParent,
entities: entities,
};
// Handle the operation using the promise pattern.
client.batchUpdateEntities(request)
.then(responses => {
const [operation, initialApiResponse] = responses;
// Operation#promise starts polling for the completion of the LRO.
return operation.promise();
})
.then(responses => {
const result = responses[0];
const metadata = responses[1];
const finalApiResponse = responses[2];
})
.catch(err => {
console.error(err);
});
const formattedParent = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
const entities = [];
const request = {
parent: formattedParent,
entities: entities,
};
// Handle the operation using the event emitter pattern.
client.batchUpdateEntities(request)
.then(responses => {
const [operation, initialApiResponse] = responses;
// Adding a listener for the "complete" event starts polling for the
// completion of the operation.
operation.on('complete', (result, metadata, finalApiResponse) => {
// doSomethingWith(result);
});
// Adding a listener for the "progress" event causes the callback to be
// called on any change in metadata when the operation is polled.
operation.on('progress', (metadata, apiResponse) => {
// doSomethingWith(metadata)
});
// Adding a listener for the "error" event handles any errors found during polling.
operation.on('error', err => {
// throw(err);
});
})
.catch(err => {
console.error(err);
});
const formattedParent = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
const entities = [];
const request = {
parent: formattedParent,
entities: entities,
};
// Handle the operation using the await pattern.
const [operation] = await client.batchUpdateEntities(request);
const [response] = await operation.promise();
batchUpdateEntityTypes
batchUpdateEntityTypes(request, options, callback) returns Promise
Updates/Creates multiple entity types in the specified agent.
Operation <response: BatchUpdateEntityTypesResponse, metadata: google.protobuf.Struct>
Parameter |
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is a gax.Operation object. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const formattedParent = client.projectAgentPath('[PROJECT]');
// Handle the operation using the promise pattern.
client.batchUpdateEntityTypes({parent: formattedParent})
.then(responses => {
const [operation, initialApiResponse] = responses;
// Operation#promise starts polling for the completion of the LRO.
return operation.promise();
})
.then(responses => {
const result = responses[0];
const metadata = responses[1];
const finalApiResponse = responses[2];
})
.catch(err => {
console.error(err);
});
const formattedParent = client.projectAgentPath('[PROJECT]');
// Handle the operation using the event emitter pattern.
client.batchUpdateEntityTypes({parent: formattedParent})
.then(responses => {
const [operation, initialApiResponse] = responses;
// Adding a listener for the "complete" event starts polling for the
// completion of the operation.
operation.on('complete', (result, metadata, finalApiResponse) => {
// doSomethingWith(result);
});
// Adding a listener for the "progress" event causes the callback to be
// called on any change in metadata when the operation is polled.
operation.on('progress', (metadata, apiResponse) => {
// doSomethingWith(metadata)
});
// Adding a listener for the "error" event handles any errors found during polling.
operation.on('error', err => {
// throw(err);
});
})
.catch(err => {
console.error(err);
});
const formattedParent = client.projectAgentPath('[PROJECT]');
// Handle the operation using the await pattern.
const [operation] = await client.batchUpdateEntityTypes({parent: formattedParent});
const [response] = await operation.promise();
createEntityType
createEntityType(request, options, callback) returns Promise
Creates an entity type in the specified agent.
Parameter |
|||||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is an object representing EntityType. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is an object representing EntityType. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const formattedParent = client.projectAgentPath('[PROJECT]');
const entityType = {};
const request = {
parent: formattedParent,
entityType: entityType,
};
client.createEntityType(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
deleteEntityType
deleteEntityType(request, options, callback) returns Promise
Deletes the specified entity type.
Parameter |
|||||
---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||
callback |
Optional function(nullable Error) The function which will be called with the result of the API call. |
- Returns
-
Promise
- The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const formattedName = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
client.deleteEntityType({name: formattedName}).catch(err => {
console.error(err);
});
entityTypePath
entityTypePath(project, entityType) returns String
Return a fully-qualified entity_type resource name string.
Parameter |
|
---|---|
project |
String |
entityType |
String |
- Returns
-
String
getEntityType
getEntityType(request, options, callback) returns Promise
Retrieves the specified entity type.
Parameter |
|||||||
---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is an object representing EntityType. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is an object representing EntityType. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const formattedName = client.entityTypePath('[PROJECT]', '[ENTITY_TYPE]');
client.getEntityType({name: formattedName})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
getProjectId
getProjectId(callback)
Return the project ID used by this class.
Parameter |
|
---|---|
callback |
function(Error, string) the callback to be called with the current project Id. |
listEntityTypes
listEntityTypes(request, options, callback) returns Promise
Returns the list of all entity types in the specified agent.
Parameter |
|||||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
callback |
Optional function(nullable Error, nullable Array, nullable Object, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is Array of EntityType. When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListEntityTypesResponse. |
- Returns
-
Promise
-
The promise which resolves to an array. The first element of the array is Array of EntityType.
When autoPaginate: false is specified through options, the array has three elements. The first element is Array of EntityType in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListEntityTypesResponse.
The promise has a method named "cancel" which cancels the ongoing API call.
-
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
// Iterate over all elements.
const formattedParent = client.projectAgentPath('[PROJECT]');
client.listEntityTypes({parent: formattedParent})
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
// doThingsWith(resource)
}
})
.catch(err => {
console.error(err);
});
// Or obtain the paged response.
const formattedParent = client.projectAgentPath('[PROJECT]');
const options = {autoPaginate: false};
const callback = responses => {
// The actual resources in a response.
const resources = responses[0];
// The next request if the response shows that there are more responses.
const nextRequest = responses[1];
// The actual response object, if necessary.
// const rawResponse = responses[2];
for (const resource of resources) {
// doThingsWith(resource);
}
if (nextRequest) {
// Fetch the next page.
return client.listEntityTypes(nextRequest, options).then(callback);
}
}
client.listEntityTypes({parent: formattedParent}, options)
.then(callback)
.catch(err => {
console.error(err);
});
listEntityTypesStream
listEntityTypesStream(request, options) returns Stream
Equivalent to listEntityTypes, but returns a NodeJS Stream object.
This fetches the paged responses for listEntityTypes 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.
Parameter |
|||||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
- See also
- https://nodejs.org/api/stream.html
- Returns
-
Stream
An object stream which emits an object representing EntityType on 'data' event.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const formattedParent = client.projectAgentPath('[PROJECT]');
client.listEntityTypesStream({parent: formattedParent})
.on('data', element => {
// doThingsWith(element)
}).on('error', err => {
console.log(err);
});
matchEntityTypeFromEntityTypeName
matchEntityTypeFromEntityTypeName(entityTypeName) returns String
Parse the entityTypeName from a entity_type resource.
Parameter |
|
---|---|
entityTypeName |
String A fully-qualified path representing a entity_type resources. |
- Returns
-
String
- A string representing the entity_type.
matchProjectFromEntityTypeName
matchProjectFromEntityTypeName(entityTypeName) returns String
Parse the entityTypeName from a entity_type resource.
Parameter |
|
---|---|
entityTypeName |
String A fully-qualified path representing a entity_type resources. |
- Returns
-
String
- A string representing the project.
matchProjectFromProjectAgentName
matchProjectFromProjectAgentName(projectAgentName) returns String
Parse the projectAgentName from a project_agent resource.
Parameter |
|
---|---|
projectAgentName |
String A fully-qualified path representing a project_agent resources. |
- Returns
-
String
- A string representing the project.
projectAgentPath
projectAgentPath(project) returns String
Return a fully-qualified project_agent resource name string.
Parameter |
|
---|---|
project |
String |
- Returns
-
String
updateEntityType
updateEntityType(request, options, callback) returns Promise
Updates the specified entity type.
Parameter |
|||||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object The request object that will be sent. Values in
|
||||||||
options |
Optional Object Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||
callback |
Optional function(nullable Error, nullable Object) The function which will be called with the result of the API call. The second parameter to the callback is an object representing EntityType. |
- Returns
-
Promise
- The promise which resolves to an array. The first element of the array is an object representing EntityType. The promise has a method named "cancel" which cancels the ongoing API call.
Example
const dialogflow = require('dialogflow');
const client = new dialogflow.v2beta1.EntityTypesClient({
// optional auth parameters.
});
const entityType = {};
client.updateEntityType({entityType: entityType})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});