Hi, I have facing the issue as below in https://glitch.com, How to resolve?
TypeError: dialogflow.SessionsClient is not a constructor
at /app/server.js:29:25
at Layer.handle [as handle_request] (/rbd/pnpm-volume/da59de95-5f29-48a0-8ac6-325d9ce14734/node_modules/.registry.npmjs.org/express/4.16.3/node_modules/express/lib/router/layer.js:95:5)
at next (/rbd/pnpm-volume/da59de95-5f29-48a0-8ac6-325d9ce14734/node_modules/.registry.npmjs.org/express/4.16.3/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/rbd/pnpm-volume/da59de95-5f29-48a0-8ac6-325d9ce14734/node_modules/.registry.npmjs.org/express/4.16.3/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/rbd/pnpm-volume/da59de95-5f29-48a0-8ac6-325d9ce14734/node_modules/.registry.npmjs.org/express/4.16.3/node_modules/express/lib/router/layer.js:95:5)
at /rbd/pnpm-volume/da59de95-5f29-48a0-8ac6-325d9ce14734/node_modules/.registry.npmjs.org/express/4.16.3/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/rbd/pnpm-volume/da59de95-5f29-48a0-8ac6-325d9ce14734/node_modules/.registry.npmjs.org/express/4.16.3/node_modules/express/lib/router/index.js:335:12)
at next (/rbd/pnpm-volume/da59de95-5f29-48a0-8ac6-325d9ce14734/node_modules/.registry.npmjs.org/express/4.16.3/node_modules/express/lib/router/index.js:275:10)
at SendStream.error (/rbd/pnpm-volume/da59de95-5f29-48a0-8ac6-325d9ce14734/node_modules/.registry.npmjs.org/serve-static/1.13.2/node_modules/serve-static/index.js:121:7)
at emitOne (events.js:116:13)
Same issue in Runkit https://runkit.com
Greetings! Can you share the exact code snippet you're trying to use? Is this running on the server, or in the browser?
Hi @prashant7july, did you resolved the issue?
I resolved it changing the version of the lib version:
from "dialogflow": "^4.0.3" to "dialogflow": "0.6.0"
source: https://www.npmjs.com/package/dialogflow
let me know if it helps
Why this issue is closed? I have the same error with runkit
Code:
try {
const event = {
call_sid: "12345678799",
speech_result: "Hola",
}
let projectId = "projectId"
let privateKey = "privateKey"
let clientEmail = "clientEmail"
let config = {
credentials: {
private_key: privateKey,
client_email: clientEmail
}
}
let sessionClient = new dialogflow.SessionsClient(config)
const sessionPath = sessionClient.sessionPath(projectId, event.call_sid);
const request = {
session: sessionPath,
queryInput: {
text: {
text: event.speech_result,
languageCode: LANGUAGE_CODE
}
}
};
console.log("sirve?");
console.log(sessionClient.detectIntent(request));
/*
sessionClient.detectIntent(request).then(element => {
console.log(element);
callback(null, element);
})
.catch(err => {
console.log(err);
callback(err);
});*/
}
catch(err) {
console.log(err);
}
This looks to be related to webpack type environments.
Hi @BlueSeph28,
What you see might be a RunKit bug. I reproduced it here: https://runkit.com/alexander-fenster/5e5d5d2e21b63e00141512ca#:

First, I tried to load another Google Cloud library (@google-cloud/speech), and it worked (at least it created a client properly).
Then, for dialogflow, weird stuff happens: for some reason, it shows the version as 4.0.3 (which is totally wrong, this package is currently at 1.2.0). Seems like for whatever reason it actually picks https://www.npmjs.com/package/apiai instead (which is _really_ old).
So, I would advice that you contact RunKit support and figure out why the wrong package gets imported.
Good news! We are planning to publish the next Dialogflow library version as @google-cloud/dialogflow (rather than just dialogflow), and it will _probably_ fix this weird bug.
@google-cloud/dialogflow didn't help me in my scenario , whereas only dialogflow worked out in a better way
An error message "sessionClient.projectAgentSessionPath is not a function
at runSample" like this is coming up on my console and i'm trying to resolve it but unable to do so. Please kindly help.
An error message "sessionClient.projectAgentSessionPath is not a function
at runSample" like this is coming up on my console and i'm trying to resolve it but unable to do so. Please kindly help.
@Mohini0104
change this "sessionClient.projectAgentSessionPath " to "sessionClient.sessionPath" . not Session its session ok.
and also change the directories "\" to "/".
@google-cloud/dialogflow didn't help me in my scenario , whereas only dialogflow worked out in a better way
remove @google-cloud and be it remain 'dialogflow'
Try removing dialogflow and reinstalling
npm uninstall dialogflow
npm install --save dialogflow
Mine worked this way
It looks like there is a workaround for this issue, so I'm going to close it. Please feel free to re-open this issue with more information.
Subject: Firebase Functions Dashboard shows this error message: " TypeError: dialogflow.SessionsClient is not a constructor" in 2021
Hi All
Our Firebase Functions web apps connected with Dialogflow platform API had worked correctly from 2017 till June/2021; Then, we updated the following libraries with our code package in July/2021; Then, our input on our web apps cannot be passed to our chatbot on Dialogflow; We found the above Error Message inside Firebase Functions Dashboard; We have done the following work to solve this issue, but the above issue cannot be fixed;
============
// Create a new session
const sessionClient = new dialogflow.SessionsClient();
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
==============
*This code package is updated with these libraries yesterday and this code package generated the above Error Message:
==========
[email protected]
[email protected]
+ [email protected]
+ [email protected]
+ [email protected]
+ @google-cloud/[email protected]
=============
*We tried to find the causes and solution for the above error over the web and the related help forums, here are what we found so far:
https://pipedream.com/apps/google-dialogflow
https://github.com/googleapis/nodejs-dialogflow/issues/288
https://github.com/googleapis/nodejs-dialogflow/issues/127
We tried several suggestions in the above posts and none worked.
*Any suggestions and help will be highly appreciated for the above urgent Error Message!!