Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function detectIntentwithTexttoSpeechResponse(
projectId,
sessionId,
query,
languageCode,
outputFile
) {
// [START dialogflow_detect_intent_with_texttospeech_response]
// Imports the Dialogflow client library
const dialogflow = require('dialogflow').v2beta1;
// Instantiate a DialogFlow client.
const sessionClient = new dialogflow.SessionsClient();
/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = 'ID of GCP project associated with your Dialogflow agent';
// const sessionId = `user specific ID of session, e.g. 12345`;
// const query = `phrase(s) to pass to detect, e.g. I'd like to reserve a room for six people`;
// const languageCode = 'BCP-47 language code, e.g. en-US';
// const outputFile = `path for audio output file, e.g. ./resources/myOutput.wav`;
// Define session path
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
const fs = require(`fs`);
async function createDocument(
projectId,
knowledgeBaseFullName,
documentPath,
documentName,
knowledgeTypes,
mimeType
) {
// [START dialogflow_create_document]
// Imports the Dialogflow client library
const dialogflow = require('dialogflow').v2beta1;
// Instantiate a DialogFlow Documents client.
const client = new dialogflow.DocumentsClient({
projectId: projectId,
});
/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = 'ID of GCP project associated with your Dialogflow agent';
// const knowledgeBaseFullName = `the full path of your knowledge base, e.g my-Gcloud-project/myKnowledgeBase`;
// const documentPath = `path of the document you'd like to add, e.g. https://dialogflow.com/docs/knowledge-connectors`;
// const documentName = `displayed name of your document in knowledge base, e.g. myDoc`;
// const knowledgeTypes = `The Knowledge type of the Document. e.g. FAQ`;
// const mimeType = `The mime_type of the Document. e.g. text/csv, text/html,text/plain, text/pdf etc.`;
async function createKnowledgeBase(projectId, displayName) {
// [START dialogflow_create_knowledge_base]
// Imports the Dialogflow client library
const dialogflow = require('dialogflow').v2beta1;
// Instantiate a DialogFlow client.
const client = new dialogflow.KnowledgeBasesClient();
/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = 'ID of GCP project associated with your Dialogflow agent';
// const displayName = `your knowledge base display name, e.g. myKnowledgeBase`;
const formattedParent = client.projectPath(projectId);
const knowledgeBase = {
displayName: displayName,
};
const request = {
parent: formattedParent,
async function detectIntentwithModelSelection(
projectId,
sessionId,
audioFilePath,
languageCode,
model
) {
// [START dialogflow_detect_intent_with_model_selection]
const fs = require('fs');
// Imports the Dialogflow client library
const dialogflow = require('dialogflow').v2beta1;
// Instantiate a DialogFlow client.
const sessionClient = new dialogflow.SessionsClient();
/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = 'ID of GCP project associated with your Dialogflow agent';
// const sessionId = `user specific ID of session, e.g. 12345`;
// const audioFilePath = `path to local audio file, e.g. ./resources/book_a_room.wav`;
// const languageCode = 'BCP-47 language code, e.g. en-US';
// const model = `speech mode selected for given request, e.g. video, phone_call, command_and_search, default`;
// Define session path
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
// Read the content of the audio file and send it as part of the request.
async function detectIntentKnowledge(
projectId,
sessionId,
languageCode,
knowledgeBaseFullName,
query
) {
// [START dialogflow_detect_intent_knowledge]
// Imports the Dialogflow client library
const dialogflow = require('dialogflow').v2beta1;
// Instantiate a DialogFlow client.
const sessionClient = new dialogflow.SessionsClient();
/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = 'ID of GCP project associated with your Dialogflow agent';
// const sessionId = `user specific ID of session, e.g. 12345`;
// const languageCode = 'BCP-47 language code, e.g. en-US';
// const knowledgeBaseFullName = `the full path of your knowledge base, e.g my-Gcloud-project/myKnowledgeBase`;
// const query = `phrase(s) to pass to detect, e.g. I'd like to reserve a room for six people`;
// Define session path
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
const knowbase = new dialogflow.KnowledgeBasesClient();