I am trying to detect an intent using the following code in nodeJS:
const session=new dialogflow.SessionsClient({ project_id:"activity3-viod", keyFilename:"assets/keys/dialogflow.json" });
const sessionPath = session.projectLocationAgentSessionPath("activity3-viod","us-central1","Test-CX","123456789");
const request = { session: sessionPath, queryInput:{ text: { text: "sample phrase", languageCode:"en-US" }}};
const responses = await session.detectIntent(request);
I get the following error:
Error: 3 INVALID_ARGUMENT: Please switch to 'us-central1-dialogflow.googleapis.com' to access resources located in 'us-central1'.
The project is indeed us-centra11 and I think the id and agent names are right. They are what DF says on the site. I thought I was addressing us-centra11?
You need to call the regional API endpoint if you use Agents outside the global
region. Check the Python example here which has an if
clause to check for regions which are not global
.
I think the Node.js example is missing the ClientOptions.