Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
manmat opened this issue Jun 8, 2024 · 1 comment
Open

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

manmat opened this issue Jun 8, 2024 · 1 comment

Comments

@manmat
Copy link

manmat commented Jun 8, 2024

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
Copy link
Author

manmat commented Jun 8, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant