- Home
- Skills
- Sickn33
- Antigravity Awesome Skills
- M365 Agents Py
m365-agents-py_skill
- Python
10.4k
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill sickn33/antigravity-awesome-skills --skill m365-agents-py- SKILL.md11.9 KB
Overview
This skill provides a Python SDK wrapper and examples for building Microsoft 365, Teams, and Copilot Studio agents using aiohttp hosting, AgentApplication routing, streaming responses, and MSAL-based authentication. It surfaces the microsoft_agents import prefix, connection patterns, and ready-to-use handlers for messages, invokes, and conversation updates. The package emphasizes secure environment configuration and production-ready storage/auth patterns.
How this skill works
The SDK wires an AgentApplication to a CloudAdapter and an aiohttp server endpoint, routing incoming Activities to decorated handlers (message, activity, conversation_update). It manages authentication via MsalConnectionManager, supports auth-protected message handlers with auth_handlers, and enables streaming responses by integrating Azure OpenAI async clients into context.streaming_response. Utility functions load configuration from environment variables and provide middleware (jwt_authorization_middleware) for request validation.
When to use it
- Build conversational agents for Microsoft Teams and Microsoft 365 using Python.
- Host agents that require MSAL-based OAuth flows and Graph API calls.
- Stream LLM-generated content (Azure OpenAI) into Teams or Copilot Studio sessions.
- Route activities with regex or string-based message handlers and add auth-protected endpoints.
- Integrate direct-to-engine Copilot Studio flows with a CopilotClient.
Best practices
- Use the microsoft_agents import prefix (underscores) to match current package structure.
- Keep secrets in environment variables and load config with load_configuration_from_env(environ).
- Use MemoryStorage only for development; switch to Blob/Cosmos storage in production.
- Include jwt_authorization_middleware in aiohttp middlewares for secure endpoints.
- Always call context.streaming_response.end_stream() in finally blocks when streaming.
- Protect OAuth routes with auth_handlers and use MsalConnectionManager for token management.
Example use cases
- Echo bot: lightweight message handler that echoes user input via AgentApplication.activity("message").
- Welcome flow: conversation_update handler to greet new members when added to a chat or team.
- Profile lookup: /me command protected by GRAPH auth_handlers to call Microsoft Graph and show the user profile.
- Streaming assistant: stream a long-form response from Azure OpenAI into Teams with informative updates and sensitivity labels.
- Copilot Studio integration: use CopilotClient to start conversations and relay engine replies to a user session.
FAQ
The package moved from microsoft.agents to microsoft_agents; update imports to use underscores.
Can I stream Azure OpenAI responses safely?
Yes. Use the AsyncAzureOpenAI client, queue_text_chunk for each chunk, and always call end_stream() in a finally block to close the stream.