Skip to content

add m365 extension package and sample - #725

Merged
Lily Du (lilyydu) merged 7 commits into
mainfrom
lilyydu/m365extensions-package
Aug 14, 2026
Merged

Lily Du (lilyydu) merged 7 commits into
mainfrom
lilyydu/m365extensions-package

Conversation

@lilyydu

@lilyydu Lily Du (lilyydu) commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a new @microsoft/teams.m365extensions package — an M365 extension that lets you run the Teams SDK for TypeScript (teams.ts) inside an existing M365 Agents app. It installs middleware that routes Teams activities to a teams.ts App, while every other channel — and any Teams turn with no matching teams.ts route — falls through to the host app's existing handlers. This lets you layer rich Teams-native features (Adaptive Cards, task modules, reactions, targeted messages) onto an app without rewriting its current message handling.

What's included

Package — packages/m365extensions/

  • useTeamsSdk(...) — one-call setup that builds the teams.ts App and installs the routing middleware.
  • TeamsMiddleware / isTeamsChannel — the middleware and a channel-detection helper.
  • Credential/token wiring (createAgentSdkTokenProvider, TeamsToken) so teams.ts's outbound calls reuse the host app's existing credentials.
  • Unit tests (src/m365extensions.spec.ts).

Example — examples/m365extensions/

  • A runnable sample demonstrating Teams-only features (help card, reactions, quoted replies, targeted messages, task modules) alongside pass-through commands handled by the host app.
  • Adaptive Cards built with the @microsoft/teams.cards builders.
  • README.md + .env.example with Teams CLI-based setup.

How it works

For each Teams turn, the middleware checks whether the teams.ts App has a matching route. If it does, teams.ts handles the turn and its response flows back through the host pipeline. If not — or for any non-Teams channel — the turn passes through unchanged to the host app.

Screenshots

Direct Line / Webchat:
image

Email:
image

Copilot AI lite review requested due to automatic review settings August 12, 2026 23:57
Comment thread packages/m365extensions/src/token.ts Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new @microsoft/teams.m365extensions package plus a runnable example that embeds a teams.ts App into a Microsoft Agents SDK AgentApplication, routing Teams turns to teams.ts when a matching route exists and falling back to host handlers otherwise.

Changes:

  • Introduces the packages/m365extensions/ package with middleware-based routing, Agents SDK credential/token bridging, and unit tests.
  • Adds examples/m365extensions/ sample demonstrating Teams-only features alongside host-app fallthrough behavior.
  • Updates package-lock.json to include the new workspace packages and resolved dependency graph updates.

Reviewed changes

Copilot reviewed 26 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/m365extensions/turbo.json Turbo build wiring for the new package.
packages/m365extensions/tsup.config.js Uses shared tsup config for package builds.
packages/m365extensions/tsconfig.json TypeScript build configuration for the package.
packages/m365extensions/src/token.ts Implements a synthetic IToken for Teams turns.
packages/m365extensions/src/middleware.ts Core routing middleware + Teams channel detection.
packages/m365extensions/src/m365extensions.spec.ts Unit tests for routing, token projection, and token provider behavior.
packages/m365extensions/src/install.ts useTeamsSdk installer that constructs the teams.ts App and installs middleware.
packages/m365extensions/src/index.ts Public exports for the new package.
packages/m365extensions/src/credentials.ts Bridges teams.ts token acquisition to Agents SDK connections.
packages/m365extensions/src/context.ts AsyncLocalStorage context bridge for Agents SDK turns.
packages/m365extensions/README.md Package-level documentation and install instructions.
packages/m365extensions/package.json New package manifest (deps/peers/scripts).
packages/m365extensions/jest.config.js Uses shared Jest config.
packages/m365extensions/eslint.config.js Uses shared ESLint config.
packages/m365extensions/CHANGELOG.md Initial changelog for the package.
package-lock.json Adds new workspace entries and updates lock resolution.
examples/m365extensions/turbo.json Turbo wiring for the example build.
examples/m365extensions/tsconfig.json TypeScript build configuration for the example.
examples/m365extensions/src/index.ts Runnable sample embedding teams.ts into an Agents SDK app.
examples/m365extensions/src/cards.ts Adaptive Card builders used by the sample.
examples/m365extensions/README.md Sample setup/run instructions and scenario walkthrough.
examples/m365extensions/package.json Example package manifest and scripts.
examples/m365extensions/eslint.config.js Uses shared ESLint config.
examples/m365extensions/CHANGELOG.md Initial changelog for the example.
examples/m365extensions/appPackage/manifest.json Teams app manifest for the sample.
examples/m365extensions/.gitignore Ignores local env/dev artifacts for the sample.
examples/m365extensions/.env.example Template env vars for Teams CLI + OAuth handler setup.

ðŸ’Ą Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/m365extensions/src/middleware.ts
Comment thread packages/m365extensions/src/index.ts
Comment thread packages/m365extensions/src/middleware.ts Outdated
@lilyydu
Lily Du (lilyydu) added this pull request to the merge queue Aug 14, 2026
Merged via the queue into main with commit bada9a3 Aug 14, 2026
9 checks passed
@lilyydu
Lily Du (lilyydu) deleted the lilyydu/m365extensions-package branch August 14, 2026 21:11
@lilyydu Lily Du (lilyydu) mentioned this pull request Sep 16, 2026
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

Successfully merging this pull request may close these issues.

4 participants