问题
I want to detect an intent with dialogflow, but my dialogflow agent's region is europe-west2 for some reasons. So to specify a location, I use the version v2beta1 of Dialogflow API like described in the documentation. But it doesn't worked and I have the following error Dialogflow server in 'us' received request for resources located in 'europe-west2-dialogflow.googleapis.com.
Code :
const sessionId = crypto.randomBytes(16).toString("hex");
// Create a new dialogflow session
const sessionClient = new Dialogflow.SessionsClient(this.dialogFlowConfig)
const sessionPath = sessionClient.projectLocationAgentSessionPath(this.projectId, "europe-west2-dialogflow.googleapis.com", sessionId);
// The text query request.
const dfRequest = {
session: sessionPath,
queryInput: {
event: {
name: "Welcome",
languageCode: DialogFlowService.LANGUAGE_CODE
}
}
}
try {
const responses = await sessionClient.detectIntent(dfRequest);
const result = responses[0].queryResult!;
Logger.debug(` Query: ${result.queryText}`);
Logger.debug(` Response: ${result.fulfillmentText}`);
if (result.intent) {
Logger.debug(` Intent: ${result.intent.displayName}`);
} else {
Logger.debug(` No intent matched.`);
}
return result
回答1:
I had the similar issue, but the below config worked to access dialogflow agent's in region europe-west2
- Set the Location as "europe-west2"
- Also need to set the SessionsClient's 'apiEndpoint' as "europe-west2-dialogflow.googleapis.com"
const sessionClient = new dialogflow.SessionsClient({ apiEndpoint: "europe-west2-dialogflow.googleapis.com" });
const sessionPath = sessionClient.projectLocationAgentSessionPath(
projectId,
"europe-west2",
sessionId
);
// The text query request.
const request = {
session: sessionPath,
queryInput: {
text: {
text: query,
languageCode: languageCode,
},
},
};
回答2:
Try to use 'europe-west2'
as location. More docs here.
来源:https://stackoverflow.com/questions/63899334/error-dialogflow-server-in-us-received-request-for-resources-located-in-eur