Building a Microsoft Teams AI Agent with .NET: Keep the Bot Thin
articleNovember 26, 2026By Ali Haghighi
The Teams integration of an operational AI prototype raised a useful architectural question: should the bot become an agent, or should it be another interface to an agent that already exists?
I prefer the second option. The investigation workflow already owns its evidence, permissions and execution limits. Moving those responsibilities into a chat handler would create a second implementation of the same rules.
This note focuses on the integration design explored during November 2026. It is not a claim that the system has been deployed to a customer's Teams tenant.
One workflow, two entry points
A minimal architecture looks like this:
Teams channel -> authenticated bot endpoint
|
Web UI ----------------> application service
|
investigation workflow
|
authorized read-only tools
|
evidence and reportThe Teams adapter translates an incoming activity into an application request. The application resolves the caller, allowed service scope and investigation identifier. The workflow owns the model calls and tool policies. A report can be presented in Teams or opened in a dedicated web interface.
If MCP is used to access telemetry or documentation, it belongs behind the application boundary. The Teams handler does not need arbitrary access to MCP tools.
Azure Bot and Microsoft Graph are different integration surfaces
An Azure Bot registration and its Teams channel configuration connect a bot endpoint to Teams messaging. Microsoft Entra identity, app permissions, installation scope and tenant policy must be configured appropriately.
Microsoft Graph is useful for separate tasks such as managing app installation, where the required permissions and policies allow it. It is not necessary to grant broad Graph permissions simply because a bot receives and responds to messages.
For the precise registration and messaging flow, follow the current Microsoft Teams SDK documentation. The messaging transport and the authorization to retrieve incident data are separate concerns.
Do not run an investigation in the message handler
Investigations can take longer than the inbound interaction should remain open. I would acknowledge an authorized request, enqueue bounded work and return an investigation identifier. A worker can persist the outcome and notify the conversation later, if proactive messaging is enabled and the app has the required installation and conversation context.
A repeated delivery of the same activity must not start unlimited investigations. Deduplicate using an authenticated conversation scope and activity identifier, and make the job submission idempotent.
Make the conversation useful without making it noisy
An incident notification should answer three questions:
- What was observed, and when?
- Which claims are supported by evidence?
- What should a responder review next?
In a channel, a short summary and a link to detailed evidence are often more useful than a full transcript. The bot can remain passive until explicitly asked for an analysis. An automatic notification policy should be separate and configurable.
Do not put restricted logs, credentials or sensitive customer data in a shared channel. The recipient scope needs to be checked independently of the person who initiated the investigation.
What I would test
- Unauthorized caller and out-of-scope service.
- Duplicate inbound activity and expired conversation context.
- A tool outage while the investigation is running.
- A notification delivery failure after the report has been persisted.
- An approval or reanalysis request that exceeds its allowed budget.
A local adapter test does not prove that a real tenant installation, authentication policy or proactive delivery works. Those need integration tests in the intended Teams environment.
The important design decision is that the chat surface does not become the owner of the investigation. It remains a convenient interface to the same governed workflow.