Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 55 additions & 7 deletions samples/app-hello-world/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ With this sample, users can:
* Tabs
* Bots
* Messaging Extensions
* Agents SDK

## Interaction with app

Expand Down Expand Up @@ -171,30 +172,50 @@ To set the **Tab as the default landing capability**, configure the 'staticTabs'

![Personal Scope Bot](Images/1.PersonalScope_Bot.png)

*Installing the Hello World app in personal scope. Once added, the bot sends a welcome message and you can interact with it through chat.*

**Hello World Tab:**

![HelloWorld](Images/2.PersonalScope_StaticTab.png)

**ME:**
*The Hello Tab displays a static page in personal scope, demonstrating how to embed custom web content within Teams.*

**Messaging Extension (ME):**

![Hello World App](Images/3.PersonalScope_MsgExtSearchQuery.png)

*Messaging extension search interface showing the "getRandomText" command, which allows users to search and insert content into conversations.*

![Hello World App](Images/4.PersonalScope_MsgExtQuery2.png)

*Search results from the messaging extension displaying randomly generated text and images that can be shared in the conversation.*

**Teams Scope**

![Hello World App](Images/TeamsScope_Bot.png)

*Bot interaction in a Teams channel. The bot responds to messages from team members and can be @mentioned for specific interactions.*

![Hello World App](Images/TeamsScope_ComposeExt_1.png)

*Opening the messaging extension compose area in a Teams conversation to search for content.*

![Hello World App](Images/TeamsScope_ComposeExt_2.png)

*Messaging extension results displayed in Teams scope, showing the preview of content before inserting into the conversation.*

![Hello World App](Images/TeamsScope_ConfigTab.png)

*Configuration page for a configurable tab in Teams, allowing users to customize tab settings before adding it to a channel.*

![Hello World App](Images/TeamsScope_FirstTab.png)

*The First Tab displaying custom content in a Teams channel, demonstrating how tabs can provide dedicated workspace within Teams.*

![Hello World App](Images/TeamsScope_SecondTab.png)

*The Second Tab showing additional content options, illustrating how multiple tabs can be used to organize different features.*

## Outlook on the web

- To view your app in Outlook on the web.
Expand All @@ -205,9 +226,31 @@ To set the **Tab as the default landing capability**, configure the 'staticTabs'

![InstallOutlook](Images/Outlook_SelectApp.png)

*Accessing the Hello World app from Outlook on the web. The app appears in the More Apps section of the sidebar.*

**Select your app icon to launch and preview your app running in Outlook on the web**

![AppOutlook](Images/Outlook_StaticTab.png)
![AppOutlook](Images/Outlook_Click_Continue.png)

*Launching the Hello World app in Outlook. Click Continue to load the app content.*

![AppOutlook](Images/Outlook_Tab_Loaded.png)

*The Hello World tab successfully loaded in Outlook on the web, displaying the same content as in Teams.*

**M365 Copilot Office**

![Copilot](Images/M365_Copilot_Office.png)

*Accessing the Hello World app from Microsoft 365 Copilot in Office on the web.*

![Copilot](Images/M365_Copilot_Click_Continue_To_Load_Tab.png)

*Loading the Hello World app in M365 Copilot. Click Continue to proceed.*

![Copilot](Images/M365_Copilot_Tab_Loaded_Successfully.png)

*The Hello World tab successfully loaded in M365 Copilot, showcasing cross-platform compatibility.*

**Note:** Similarly, you can test your application in the Outlook desktop app as well.

Expand All @@ -221,19 +264,24 @@ To set the **Tab as the default landing capability**, configure the 'staticTabs'

![InstallOffice](Images/Office_M365.png)

*Finding the Hello World app in the Office on the web Apps section.*

**Select your app icon to launch your app in Office on the web**

![AppOffice](Images/Office_M365_App.png)

**Note:** Similarly, you can test your application in the Office 365 desktop app as well.

## Deploy the bot to Azure
*The Hello World app running in Office on the web, demonstrating Microsoft 365 integration.*

To learn more about deploying a bot to Azure, see [Deploy your bot to Azure](https://aka.ms/azuredeployment) for a complete list of deployment instructions.
**Note:** Similarly, you can test your application in the Office 365 desktop app as well.

## Further reading

- [Bot Framework Documentation](https://docs.botframework.com)
- [Microsoft 365 Agents SDK Documentation](https://aka.ms/agents)
- [Microsoft 365 Agents SDK for Python - GitHub](https://github.com/microsoft/Agents)
- [Microsoft 365 Agents SDK Python Samples](https://github.com/microsoft/Agents/tree/main/samples/python)
- [Building Conversational Agents with Microsoft 365 Agents SDK](https://learn.microsoft.com/microsoft-365-copilot/extensibility/overview-agents-sdk)
- [Azure Bot Service Introduction](https://docs.microsoft.com/azure/bot-service/bot-service-overview-introduction?view=azure-bot-service-4.0)
- [Extend Teams apps across Microsoft 365](https://learn.microsoft.com/en-us/microsoftteams/platform/m365-apps/overview)
- [Bot Basics](https://docs.microsoft.com/azure/bot-service/bot-builder-basics?view=azure-bot-service-4.0)
- [Azure Bot Service Introduction](https://docs.microsoft.com/azure/bot-service/bot-service-overview-introduction?view=azure-bot-service-4.0)
- [Azure Bot Service Documentation](https://docs.microsoft.com/azure/bot-service/?view=azure-bot-service-4.0)
Expand Down
45 changes: 32 additions & 13 deletions samples/app-hello-world/python/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,34 @@

import sys
import traceback
import uuid
from datetime import datetime
from http import HTTPStatus
from aiohttp import web
from aiohttp.web import Request, Response, json_response
from botbuilder.core import (
TurnContext
)
from botbuilder.integration.aiohttp import CloudAdapter, ConfigurationBotFrameworkAuthentication
from botbuilder.core.integration import aiohttp_error_middleware
from botbuilder.schema import Activity, ActivityTypes
from aiohttp.web import Request, Response
from microsoft_agents.hosting.core import TurnContext
from microsoft_agents.hosting.aiohttp import CloudAdapter
from microsoft_agents.authentication.msal import MsalConnectionManager
from microsoft_agents.hosting.aiohttp import jwt_authorization_middleware
from microsoft_agents.activity import Activity, ActivityTypes, load_configuration_from_env
from os import environ
from bots import HelloWorldBot
from config import DefaultConfig

CONFIG = DefaultConfig()

# Create adapter.
# See https://aka.ms/about-bot-adapter to learn more about how bots work.
ADAPTER = CloudAdapter(ConfigurationBotFrameworkAuthentication(CONFIG))
# Set up environment variables for Agent SDK
# The Agent SDK expects specific environment variable format for service connection
environ.setdefault("CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTID", CONFIG.APP_ID)
environ.setdefault("CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTSECRET", CONFIG.APP_PASSWORD)
environ.setdefault("CONNECTIONS__SERVICE_CONNECTION__SETTINGS__TENANTID", CONFIG.APP_TENANTID)

# Load configuration from environment using Agent SDK helper
agents_sdk_config = load_configuration_from_env(environ)

# Create connection manager for authentication
CONNECTION_MANAGER = MsalConnectionManager(**agents_sdk_config)

# Create adapter with connection manager
ADAPTER = CloudAdapter(connection_manager=CONNECTION_MANAGER)

# Catch-all for errors.
async def on_error(context: TurnContext, error: Exception):
Expand Down Expand Up @@ -97,8 +104,20 @@ async def configure(request):
async def messages(req: Request) -> Response:
return await ADAPTER.process(req, bot)

# Custom middleware wrapper to apply JWT only to /api/messages
@web.middleware
async def conditional_jwt_middleware(request, handler):
# Only apply JWT authentication to /api/messages endpoint
if request.path.startswith('/api/messages'):
return await jwt_authorization_middleware(request, handler)
else:
# For other routes (tabs, static pages), skip JWT validation
return await handler(request)

APP = web.Application(middlewares=[conditional_jwt_middleware])

APP = web.Application(middlewares=[aiohttp_error_middleware])
# Set the agent configuration in app state for jwt_authorization_middleware
APP["agent_configuration"] = CONNECTION_MANAGER.get_default_connection_configuration()

# Register routes
APP.router.add_get("/", home)
Expand Down
2 changes: 1 addition & 1 deletion samples/app-hello-world/python/assets/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"The Microsoft Teams Python Hello World Sample app demonstrates key features of Teams, including tabs, bots, and messaging extensions, built with Python. It’s a great starting point for developing and deploying custom Teams apps."
],
"creationDateTime": "2024-12-12",
"updateDateTime": "2024-12-12",
"updateDateTime": "2025-12-01",
"products": [
"Teams"
],
Expand Down
14 changes: 8 additions & 6 deletions samples/app-hello-world/python/bots/bot.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from botbuilder.core import TurnContext, CardFactory
from botbuilder.core.teams import TeamsActivityHandler
from botbuilder.schema.teams import TeamInfo, TeamsChannelAccount
from microsoft_agents.hosting.core import TurnContext, CardFactory
from microsoft_agents.hosting.teams import TeamsActivityHandler
from microsoft_agents.activity.teams import TeamInfo, TeamsChannelAccount
from faker import Faker
from botbuilder.schema.teams import (
from microsoft_agents.activity.teams import (
MessagingExtensionResponse,
MessagingExtensionAttachment,
MessagingExtensionResult,
)
from botbuilder.schema import (
from microsoft_agents.activity import (
ThumbnailCard,
CardImage,
CardAction,
)


class HelloWorldBot(TeamsActivityHandler):
"""
A bot class that handles activities for Microsoft Teams, including messaging,
Expand Down Expand Up @@ -105,6 +104,7 @@ async def on_teams_messaging_extension_query(self, context, query):
preview_card = self.create_thumbnail_card(title, text, images)
tap_action = CardAction(
type="invoke",
title=title,
value={"title": title, "text": text, "images": images},
)
preview_attachment = CardFactory.thumbnail_card(preview_card)
Expand All @@ -114,6 +114,7 @@ async def on_teams_messaging_extension_query(self, context, query):
attachment = MessagingExtensionAttachment(
content=thumbnail_card,
content_type=CardFactory.content_types.thumbnail_card,
content_url="",
preview=preview_attachment,
)
attachments.append(attachment)
Expand Down Expand Up @@ -149,6 +150,7 @@ async def on_teams_messaging_extension_select_item(
attachment = MessagingExtensionAttachment(
content_type=CardFactory.content_types.thumbnail_card,
content=thumbnail_card,
content_url="",
)

return MessagingExtensionResponse(
Expand Down
3 changes: 2 additions & 1 deletion samples/app-hello-world/python/env/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ MICROSOFT_APP_TENANT_ID=
RESOURCE_SUFFIX=
AZURE_SUBSCRIPTION_ID=
AZURE_RESOURCE_GROUP_NAME=
APP_NAME_SUFFIX=
APP_NAME_SUFFIX=
AAD_APP_ACCESS_AS_USER_PERMISSION_ID=
9 changes: 7 additions & 2 deletions samples/app-hello-world/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
requests==2.31.0
botbuilder-integration-aiohttp>=4.14.5
requests>=2.32.3
microsoft-agents-activity>=0.6.0
microsoft-agents-hosting-core>=0.6.0
microsoft-agents-hosting-aiohttp>=0.6.0
microsoft-agents-hosting-teams>=0.6.0
microsoft-agents-authentication-msal>=0.6.0
faker>=18.0.0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
69 changes: 24 additions & 45 deletions samples/graph-chat-lifecycle/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This sample application showcases the management of chat lifecycles in Microsoft
* Tabs
* Adaptive Cards
* Graph API
* Agent SDK

## Interaction with app

Expand Down Expand Up @@ -166,63 +167,41 @@ The simplest way to run this sample in Teams is to use Microsoft 365 Agents Tool

## Running the sample

1. In Teams, Install App
- **Install App:**
![Install the Chat Lifecycle app in Teams](Images/1.Install.png)

![](Images/Install.png)

![](Images/SelectTeams.png)

![](Images/InstallSaveTab.png)

2. In Teams, Once the app is successfully installed, it can be opened in the tab and has option to create group chat if user is authenticated.

![](Images/WelcomeCreateGroup.png)

3. Once create group chat is clicked, user will be able to add Title of the groupchat and select users from drop down to create a group chat and add members (using different scenarios) and delete member accordingly to depict the lifecycle of chat.

![](Images/CreateGroupChat.png)

![](Images/MembersList.png)

![](Images/CreateGroupChatDetails.png)

![](Images/GroupChatCreatedSuccessfully.png)

4. Also, Polly app will be installed to the created group chat and will be pinned to the chat.

![](Images/PinnedTabSuccessfully.png)

## Outlook on the web

- To view your app in Outlook on the web.

- Go to [Outlook on the web](https://outlook.office.com/mail/)and sign in using your dev tenant account.

**On the side bar, select More Apps. Your uploaded app title appears among your installed apps**

![InstallOutlook](Images/InstallOutlook.png)
- **Add To Group Chat:**
![Add the app to an existing group chat](Images/2.Add_To_GroupChat.png)

**Select your app icon to launch and preview your app running in Outlook on the web**
- **Open Configurable Tab:**
![Open the configurable tab to set up the app](Images/3.Configurable_Tab.png)

![AppOutlook](Images/AppOutlook.png)
- **Tab Added Successfully:**
![Confirmation that the tab was added successfully](Images/4.Tab_Added_Successfully.png)

**Note:** Similarly, you can test your application in the Outlook desktop app as well.
- **Create Group Chat (Adaptive Card):**
![Adaptive card used to create a group chat](Images/5.Create_Group_Chat.png)

## Office on the web
- **Group Chat Created Successfully:**
![Success message after creating group chat and installing app](Images/6.Created_GC_Successfully.png)

- To preview your app running in Office on the web.
- **App In Outlook:**
![The app shown in Outlook on the web](Images/7.In_Outlook.png)

- Log into office.com with test tenant credentials
- **Outlook Tab View:**
![The app loaded as a tab inside Outlook](Images/8.Outlook_Tab.png)

**Select the Apps icon on the side bar. Your uploaded app title appears among your installed apps**
- **M365 Copilot Integration:**
![App appearing within the M365 Copilot experience](Images/9.M365_Copilot_Office.png)

![InstallOffice](Images/InstallOffice.png)
- **Continue in M365 Copilot:**
![Continue flow inside M365 Copilot after opening the app](Images/10.Continue_M365_Copilot.png)

**Select your app icon to launch your app in Office on the web**
- **Tab Loaded in M365 Copilot:**
![Final view of the tab loaded in the M365 Copilot surface](Images/11.Tab_Loaded_In_M365_Copilot.png)

![AppOffice](Images/AppOffice.png)

**Note:** Similarly, you can test your application in the Office 365 desktop app as well.
**Note:** Similarly, you can test your application in the Office M365 Copilot desktop app as well.

## Further Reading
[Graph-Chat-Life-Cycle](https://learn.microsoft.com/en-us/microsoftteams/plan-teams-lifecycle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
"configurationUrl": "https://${{TAB_DOMAIN}}/configure",
"canUpdateConfiguration": true,
"scopes": [
"team"
"team",
"groupChat"

]
}
],
Expand Down
2 changes: 1 addition & 1 deletion samples/graph-chat-lifecycle/nodejs/assets/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"This sample application illustrates the full lifecycle of chats in Microsoft Teams, allowing users to create chats, add and remove members, and interact with the application using Microsoft Graph APIs. Built with Node.js, it features tabs, adaptive cards, and a seamless setup process using the Teams Toolkit for Visual Studio Code."
],
"creationDateTime": "2021-07-07",
"updateDateTime": "2024-10-14",
"updateDateTime": "2025-11-28",
"products": [
"Teams"
],
Expand Down
2 changes: 1 addition & 1 deletion samples/graph-chat-lifecycle/nodejs/helpers/chatHelper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const ACData = require("adaptivecards-templating");
const { CardFactory } = require('botbuilder');
const { CardFactory } = require('@microsoft/agents-hosting');
require('isomorphic-fetch');
const { Client } = require("@microsoft/microsoft-graph-client");
const config = require('../config/default.json');
Expand Down
Loading