GoogleCloudPlatform / dialogflow-integrations

Dialogflow integrations with multiple platforms including KIK, Skype, Spark, Twlio, Twitter and Viber
https://cloud.google.com/dialogflow/
Apache License 2.0
246 stars 499 forks source link

Azure bot connector code fails to deploy as cloud function #245

Open manmat opened 3 weeks ago

manmat commented 3 weeks ago

I tried to deploy the minimal example and got the following error:

Function failed on loading user code. This is likely due to a bug in the user code. Error message: Provided module can't be loaded. Is there a syntax error in your code? Detailed stack trace: /workspace/node_modules/botframework-connector/node_modules/https-proxy-agent/dist/index.js:55 this.proxyHeaders = opts?.headers ?? {}; ^ SyntaxError: Unexpected token '.' at wrapSafe (internal/modules/cjs/loader.js:915:16) at Module._compile (internal/modules/cjs/loader.js:963:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) at Module.load (internal/modules/cjs/loader.js:863:32) at Function.Module._load (internal/modules/cjs/loader.js:708:14) at Module.require (internal/modules/cjs/loader.js:887:19) at require (internal/modules/cjs/helpers.js:74:18) at Object.<anonymous> (/workspace/node_modules/botframework-connector/lib/auth/openIdMetadata.js:23:29) at Module._compile (internal/modules/cjs/loader.js:999:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) Could not load the function, shutting down.. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.

I have only modified the app part of the code like so:

app.post('/', (req, res) => {
  // Use the adapter to process the incoming web request into a TurnContext object.
  //adapter.processActivity(req, res, async (turnContext) => {
  botAdapter.process(req, res, async (turnContext) => {
    if (isMessage(turnContext)) {
      const utterance = turnContext.activity.text;
      const senderId = turnContext.activity.from.id;

      // const responses = (await dialogflowClient.detectIntent(
      //     utterance, senderId)).responseMessages;

      // for (let response of responses) {
      //   if (response.message === 'text') {
      //     await turnContext.sendActivity(response.text.text.join());
      //   }
      await turnContext.sendActivity("Hello, the bot is working.");
      // }
    }
  });
});

I also made sure to remove the dialogflowClient definition and the import for dialogflowSessionClient.

manmat commented 3 weeks ago

The issue is that the deployment uses node12, I tried deploying it with node 20 and that solved the problem.