Skip to content

GCP deployment guide uses incorrect approach for Bot Framework messaging - needs CloudAdapter implementation #303

@sellakumaran

Description

@sellakumaran

Problem

The current GCP deployment documentation at https://learn.microsoft.com/en-us/microsoft-agent-365/developer/deploy-agent-gcp#create-project provides a basic Express.js implementation that doesn't properly handle Bot Framework token acquisition and response routing.

The documented sample code uses a simple Express endpoint that returns a reply object directly:

app.post("/api/messages", (req, res) => {
  console.log("Received activity:", JSON.stringify(req.body, null, 2));
  // Echo activity
  const reply = {
    type: "message",
    text: `You said: ${req.body?.text}`
  };
  res.status(200).send(reply);
});

This approach has led partners (including DBS and others) to implement custom getBotFrameworkToken() functions and manual token management, which is unnecessary and error-prone.

Expected Behavior

The documentation should demonstrate the correct pattern using CloudAdapter from @microsoft/agents-hosting, which handles Bot Framework token acquisition and reply routing automatically.

Recommended Solution

Update the GCP deployment documentation to align with the patterns used in our official samples:

Entry point pattern (from nodejs/openai/sample-agent/src/index.ts):

server.post('/api/messages', (req: Request, res: Response) => {
  const adapter = agentApplication.adapter as CloudAdapter;
  adapter.process(req, res, async (context) => {
    await agentApplication.run(context);
  });
});

Sending responses (from nodejs/openai/sample-agent/src/agent.ts):

await turnContext.sendActivity(response);

Key Points to Include in Documentation

  1. CloudAdapter reads the serviceUrl from the incoming activity
  2. It handles Bot Framework token acquisition internally
  3. It routes replies back to Teams without custom token logic
  4. @microsoft/agents-hosting is platform-agnostic and works on any platform (Azure, GCP, AWS)
  5. No manual token management is required

Impact

  • Partners are implementing workarounds with custom token management
  • Increased support burden due to incorrect implementation patterns
  • Security risks from improper token handling
  • Inconsistency between documentation and official samples

Related Resources

Customer Feedback Source

Multiple partners (DBS, Wajeed Shaikh) have reported following the current documentation and needing to implement custom token management solutions.

Metadata

Metadata

Assignees

Labels

P1Very high prioritydocumentationImprovements or additions to documentationsecuritySecurity-related issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions