|
| 1 | +# Microsoft Agents Activity |
| 2 | + |
| 3 | +[](https://pypi.org/project/microsoft-agents-activity/) |
| 4 | + |
| 5 | +Core types and schemas for building conversational AI agents that work across Microsoft 365 platforms like Teams, Copilot Studio, and Webchat. |
| 6 | + |
| 7 | +# What is this? |
| 8 | + |
| 9 | +This library is part of the **Microsoft 365 Agents SDK for Python** - a comprehensive framework for building enterprise-grade conversational AI agents. The SDK enables developers to create intelligent agents that work across multiple platforms including Microsoft Teams, M365 Copilot, Copilot Studio, and web chat, with support for third-party integrations like Slack, Facebook Messenger, and Twilio. |
| 10 | + |
| 11 | +## Packages Overview |
| 12 | + |
| 13 | +We offer the following PyPI packages to create conversational experiences based on Agents: |
| 14 | + |
| 15 | +| Package Name | PyPI Version | Description | |
| 16 | +|--------------|-------------|-------------| |
| 17 | +| `microsoft-agents-activity` | [](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. | |
| 18 | +| `microsoft-agents-hosting-core` | [](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. | |
| 19 | +| `microsoft-agents-hosting-aiohttp` | [](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. | |
| 20 | +| `microsoft-agents-hosting-teams` | [](https://pypi.org/project/microsoft-agents-hosting-teams/) | Provides classes to host an Agent for Teams. | |
| 21 | +| `microsoft-agents-storage-blob` | [](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. | |
| 22 | +| `microsoft-agents-storage-cosmos` | [](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. | |
| 23 | +| `microsoft-agents-authentication-msal` | [](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. | |
| 24 | + |
| 25 | +Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio: |
| 26 | + |
| 27 | +| Package Name | PyPI Version | Description | |
| 28 | +|--------------|-------------|-------------| |
| 29 | +| `microsoft-agents-copilotstudio-client` | [](https://pypi.org/project/microsoft-agents-copilotstudio-client/) | Direct to Engine client to interact with Agents created in CopilotStudio | |
| 30 | + |
| 31 | +## Architecture |
| 32 | + |
| 33 | +The SDK follows a modular architecture: |
| 34 | +- **Activity Layer**: Protocol definitions for cross-platform messaging |
| 35 | +- **Hosting Layer**: Core agent lifecycle, middleware, and web hosting |
| 36 | +- **Storage Layer**: Persistent state management with Azure backends |
| 37 | +- **Authentication Layer**: Secure identity and token management |
| 38 | +- **Integration Layer**: Platform-specific adapters (Teams, Copilot Studio) |
| 39 | + |
| 40 | +## Installation |
| 41 | + |
| 42 | +```bash |
| 43 | +pip install microsoft-agents-activity |
| 44 | +``` |
| 45 | + |
| 46 | +## Quick Start |
| 47 | +Code below taken from the [Quick Start](https://github.com/microsoft/Agents/tree/main/samples/python/quickstart) sample. |
| 48 | +```python |
| 49 | +@AGENT_APP.conversation_update("membersAdded") |
| 50 | +async def on_members_added(context: TurnContext, _state: TurnState): |
| 51 | + await context.send_activity( |
| 52 | + "Welcome to the empty agent! " |
| 53 | + "This agent is designed to be a starting point for your own agent development." |
| 54 | + ) |
| 55 | + return True |
| 56 | + |
| 57 | + |
| 58 | +@AGENT_APP.message(re.compile(r"^hello$")) |
| 59 | +async def on_hello(context: TurnContext, _state: TurnState): |
| 60 | + await context.send_activity("Hello!") |
| 61 | + |
| 62 | + |
| 63 | +@AGENT_APP.activity("message") |
| 64 | +async def on_message(context: TurnContext, _state: TurnState): |
| 65 | + await context.send_activity(f"you said: {context.activity.text}") |
| 66 | +``` |
| 67 | + |
| 68 | +## Common Use Cases |
| 69 | + |
| 70 | +### Rich Messages with Cards |
| 71 | +Code below taken from the [Cards](https://github.com/microsoft/Agents/tree/main/samples/python/cards) sample. |
| 72 | + |
| 73 | + |
| 74 | +```python |
| 75 | + @staticmethod |
| 76 | + async def send_animation_card(context: TurnContext): |
| 77 | + card = CardFactory.animation_card( |
| 78 | + AnimationCard( |
| 79 | + title="Microsoft Agents Framework", |
| 80 | + image=ThumbnailUrl( |
| 81 | + url="https://i.giphy.com/Ki55RUbOV5njy.gif", alt="Cute Robot" |
| 82 | + ), |
| 83 | + media=[MediaUrl(url="https://i.giphy.com/Ki55RUbOV5njy.gif")], |
| 84 | + subtitle="Animation Card", |
| 85 | + text="This is an example of an animation card using a gif.", |
| 86 | + aspect="16:9", |
| 87 | + duration="PT2M", |
| 88 | + ) |
| 89 | + ) |
| 90 | + await CardMessages.send_activity(context, card) |
| 91 | + |
| 92 | + @staticmethod |
| 93 | + async def send_activity(context: TurnContext, card: Attachment): |
| 94 | + activity = Activity(type=ActivityTypes.message, attachments=[card]) |
| 95 | + await context.send_activity(activity) |
| 96 | +``` |
| 97 | + |
| 98 | +## Activity Types |
| 99 | + |
| 100 | +The library supports different types of communication: |
| 101 | + |
| 102 | +- **Message** - Regular chat messages with text, cards, attachments |
| 103 | +- **Typing** - Show typing indicators |
| 104 | +- **ConversationUpdate** - People joining/leaving chats |
| 105 | +- **Event** - Custom events and notifications |
| 106 | +- **Invoke** - Direct function calls |
| 107 | +- **EndOfConversation** - End chat sessions |
| 108 | + |
| 109 | +## Key Features |
| 110 | + |
| 111 | +✅ **Type-safe** - Built with Pydantic for automatic validation |
| 112 | +✅ **Rich content** - Support for cards, images, videos, and interactive elements |
| 113 | +✅ **Teams ready** - Full Microsoft Teams integration |
| 114 | +✅ **Cross-platform** - Works across all Microsoft 365 chat platforms |
| 115 | +✅ **Migration friendly** - Easy upgrade from Bot Framework |
| 116 | + |
| 117 | +# Quick Links |
| 118 | + |
| 119 | +- 📦 [All SDK Packages on PyPI](https://pypi.org/search/?q=microsoft-agents) |
| 120 | +- 📖 [Complete Documentation](https://aka.ms/agents) |
| 121 | +- 💡 [Python Samples Repository](https://github.com/microsoft/Agents/tree/main/samples/python) |
| 122 | +- 🐛 [Report Issues](https://github.com/microsoft/Agents-for-python/issues) |
| 123 | + |
| 124 | +# Sample Applications |
| 125 | +Explore working examples in the [Python samples repository](https://github.com/microsoft/Agents/tree/main/samples/python): |
| 126 | + |
| 127 | +|Name|Description|README| |
| 128 | +|----|----|----| |
| 129 | +|Quickstart|Simplest agent|[Quickstart](https://github.com/microsoft/Agents/blob/main/samples/python/quickstart/README.md)| |
| 130 | +|Auto Sign In|Simple OAuth agent using Graph and GitHub|[auto-signin](https://github.com/microsoft/Agents/blob/main/samples/python/auto-signin/README.md)| |
| 131 | +|OBO Authorization|OBO flow to access a Copilot Studio Agent|[obo-authorization](https://github.com/microsoft/Agents/blob/main/samples/python/obo-authorization/README.md)| |
| 132 | +|Semantic Kernel Integration|A weather agent built with Semantic Kernel|[semantic-kernel-multiturn](https://github.com/microsoft/Agents/blob/main/samples/python/semantic-kernel-multiturn/README.md)| |
| 133 | +|Streaming Agent|Streams OpenAI responses|[azure-ai-streaming](https://github.com/microsoft/Agents/blob/main/samples/python/azureai-streaming/README.md)| |
| 134 | +|Copilot Studio Client|Console app to consume a Copilot Studio Agent|[copilotstudio-client](https://github.com/microsoft/Agents/blob/main/samples/python/copilotstudio-client/README.md)| |
| 135 | +|Cards Agent|Agent that uses rich cards to enhance conversation design |[cards](https://github.com/microsoft/Agents/blob/main/samples/python/cards/README.md)| |
0 commit comments