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

安稳与你 提交于 2021-02-10 07:42:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!