Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : Dialogflow server in 'us' received request for resources located in 'europe-west2-dialogflow.googleapis.com.'

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
like image 857
Elkios Avatar asked Mar 02 '23 01:03

Elkios


1 Answers

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,
            },
        },
    };
like image 129
kishor Avatar answered May 14 '23 05:05

kishor