Diologflow

node v15.14.0
version: 1.0.0
endpointsharetweet
const dialogflow = require("dialogflow"); const dialogflowConfig ={ projectId:"ppph-ykvoku", privateKey:"6856eed8b7354fa2d5033464473652bb0c71f754", clientEmail:"[email protected]"}; const projectId = dialogflowConfig.projectId; const configuration = { credentials: { private_key: dialogflowConfig.privateKey, client_email: dialogflowConfig.clientEmail } }; const sessionId = "12345"; const languageCode = "ru"; const sessionClient = new dialogflow.SessionsClient(configuration); const sessionPath = sessionClient.sessionPath(projectId, sessionId); async function talkToChatbot(message) { console.log("message " + message); const botRequest = { session: sessionPath, queryInput: { text: { text: "привет", languageCode } } }; const response = await sessionClient .detectIntent(botRequest) .then((responses) => { console.log(JSON.stringify(responses)); const requiredResponse = responses[0].queryResult; return requiredResponse; }) .catch((error) => { console.log("ERROR: " + error); }); return response; }
Loading…

no comments

    sign in to comment