Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as dialogflow from "dialogflow";
const agentsClient = new dialogflow.AgentsClient();
const contextsClient = new dialogflow.ContextsClient();
const entityTypesClient = new dialogflow.EntityTypesClient();
const intentsClient = new dialogflow.IntentsClient();
const sessionEntityTypesClient = new dialogflow.SessionEntityTypesClient();
const sessionsClient = new dialogflow.SessionsClient();
// TODO: Add real significant tests
async function listSessionEntityTypes(projectId, sessionId) {
// Imports the Dialogflow library
const dialogflow = require('dialogflow');
// Instantiates clients
const sessionEntityTypesClient = new dialogflow.SessionEntityTypesClient();
const sessionPath = sessionEntityTypesClient.sessionPath(
projectId,
sessionId
);
const request = {
parent: sessionPath,
};
// Send the request for retrieving the sessionEntityType.
const [response] = await sessionEntityTypesClient.listSessionEntityTypes(
request
);
response.forEach(sessionEntityType => {
console.log(`Session entity type name: ${sessionEntityType.name}`);
console.log(`Number of entities: ${sessionEntityType.entities.length}\n`);
async function deleteSessionEntityType(
projectId,
sessionId,
entityTypeDisplayName
) {
// Imports the Dialogflow library
const dialogflow = require('dialogflow');
// Instantiates clients
const sessionEntityTypesClient = new dialogflow.SessionEntityTypesClient();
// The path to identify the sessionEntityType to be deleted.
const sessionEntityTypePath = sessionEntityTypesClient.sessionEntityTypePath(
projectId,
sessionId,
entityTypeDisplayName
);
const request = {
name: sessionEntityTypePath,
};
// Send the request for retrieving the sessionEntityType.
const result = await sessionEntityTypesClient.deleteSessionEntityType(
request
);
async function createSessionEntityType(
projectId,
sessionId,
entityValues,
entityTypeDisplayName,
entityOverrideMode
) {
// Imports the Dialogflow library
const dialogflow = require('dialogflow');
// Instantiates clients
const sessionEntityTypesClient = new dialogflow.SessionEntityTypesClient();
const sessionPath = sessionEntityTypesClient.sessionPath(
projectId,
sessionId
);
const sessionEntityTypePath = sessionEntityTypesClient.sessionEntityTypePath(
projectId,
sessionId,
entityTypeDisplayName
);
// Here we use the entity value as the only synonym.
const entities = [];
entityValues.forEach(entityValue => {
entities.push({
value: entityValue,