-
Notifications
You must be signed in to change notification settings - Fork 12
fix meetingStart and meetingEnd casing bug & add meetings sample #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
90fd485
add meetings sample and update casing
a94dd4b
update general README
1d4255f
remove extra slash
93952a8
update README and optional role param
0db69e1
Merge branch 'main' into lilyydu/meetings-casing
lilyydu 7a28484
update msg handler and use Field from pydantic
592c10f
fix tpo
075fe2d
added tests for deserialization
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Sample: Meetings | ||
|
|
||
| This sample demonstrates how to handle real-time updates for meeting events and meeting participant events. | ||
|
|
||
| ## Manifest Requirements | ||
|
|
||
| There are a few requirements in the Teams app manifest (manifest.json) to support these events. | ||
|
|
||
| 1) The `scopes` section must include `team`, and `groupChat`: | ||
|
|
||
| ```json | ||
| "bots": [ | ||
| { | ||
| "botId": "", | ||
| "scopes": [ | ||
| "team", | ||
| "personal", | ||
| "groupChat" | ||
| ], | ||
| "isNotificationOnly": false | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| 2) In the authorization section, make sure to specify the following resource-specific permissions: | ||
|
|
||
| ```json | ||
| "authorization":{ | ||
| "permissions":{ | ||
| "resourceSpecific":[ | ||
| { | ||
| "name":"OnlineMeetingParticipant.Read.Chat", | ||
| "type":"Application" | ||
| }, | ||
| { | ||
| "name":"ChannelMeeting.ReadBasic.Group", | ||
| "type":"Application" | ||
| }, | ||
| { | ||
| "name":"OnlineMeeting.ReadBasic.Chat", | ||
| "type":"Application" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Teams Developer Portal: Bot Configuration | ||
|
|
||
| For your Bot, make sure the [Meeting Event Subscriptions](https://learn.microsoft.com/en-us/microsoftteams/platform/apps-in-teams-meetings/meeting-apps-apis?branch=pr-en-us-8455&tabs=channel-meeting%2Cguest-user%2Cone-on-one-call%2Cdotnet3%2Cdotnet2%2Cdotnet%2Cparticipant-join-event%2Cparticipant-join-event1#receive-meeting-participant-events) are checked. | ||
| This enables you to receive the Meeting Participant events. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [project] | ||
| name = "meetings" | ||
| version = "0.1.0" | ||
| description = "Meetings app" | ||
| readme = "README.md" | ||
| requires-python = ">=3.12,<3.14" | ||
| dependencies = [ | ||
| "dotenv>=0.9.9", | ||
| "microsoft-teams-apps", | ||
| "microsoft-teams-api", | ||
| "microsoft-teams-cards", | ||
| ] | ||
|
|
||
| [tool.uv.sources] | ||
| microsoft-teams-apps = { workspace = true } | ||
| microsoft-teams-api = { workspace = true } | ||
| microsoft-teams-cards = { workspace = true } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
|
|
||
| import asyncio | ||
|
|
||
| from microsoft_teams.api.activities.event import ( | ||
| MeetingEndEventActivity, | ||
| MeetingParticipantJoinEventActivity, | ||
| MeetingParticipantLeaveEventActivity, | ||
| MeetingStartEventActivity, | ||
| ) | ||
| from microsoft_teams.api.activities.message import MessageActivity | ||
| from microsoft_teams.api.activities.typing import TypingActivityInput | ||
| from microsoft_teams.apps import ActivityContext, App | ||
| from microsoft_teams.cards import AdaptiveCard, OpenUrlAction, TextBlock | ||
|
|
||
| app = App() | ||
|
|
||
|
|
||
| @app.on_meeting_start | ||
| async def handle_meeting_start(ctx: ActivityContext[MeetingStartEventActivity]): | ||
| meeting_data = ctx.activity.value | ||
| start_time = meeting_data.start_time.strftime("%c") | ||
|
|
||
| card = AdaptiveCard( | ||
| body=[ | ||
| TextBlock( | ||
| text=f"'{meeting_data.title}' has started at {start_time}.", | ||
| wrap=True, | ||
| weight="Bolder", | ||
| ) | ||
| ], | ||
| actions=[OpenUrlAction(url=meeting_data.join_url, title="Join the meeting")], | ||
| ) | ||
|
|
||
| await ctx.send(card) | ||
|
|
||
|
|
||
| @app.on_meeting_end | ||
| async def handle_meeting_end(ctx: ActivityContext[MeetingEndEventActivity]): | ||
| meeting_data = ctx.activity.value | ||
| end_time = meeting_data.end_time.strftime("%c") | ||
| card = AdaptiveCard( | ||
| body=[ | ||
| TextBlock( | ||
| text=f"'{meeting_data.title}' has ended at {end_time}.", | ||
| wrap=True, | ||
| weight="Bolder", | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| await ctx.send(card) | ||
|
|
||
|
|
||
| @app.on_meeting_participant_join | ||
| async def handle_meeting_participant_join(ctx: ActivityContext[MeetingParticipantJoinEventActivity]): | ||
| meeting_data = ctx.activity.value | ||
| member = meeting_data.members[0].user.name | ||
| role = meeting_data.members[0].meeting.role if hasattr(meeting_data.members[0].meeting, "role") else "a participant" | ||
|
|
||
| card = AdaptiveCard( | ||
| body=[ | ||
| TextBlock( | ||
| text=f"{member} has joined the meeting as {role}.", | ||
| wrap=True, | ||
| weight="Bolder", | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| await ctx.send(card) | ||
|
|
||
|
|
||
| @app.on_meeting_participant_leave | ||
| async def handle_meeting_participant_leave(ctx: ActivityContext[MeetingParticipantLeaveEventActivity]): | ||
| meeting_data = ctx.activity.value | ||
| member = meeting_data.members[0].user.name | ||
|
|
||
| card = AdaptiveCard( | ||
| body=[ | ||
| TextBlock( | ||
| text=f"{member} has left the meeting.", | ||
| wrap=True, | ||
| weight="Bolder", | ||
| ) | ||
| ] | ||
| ) | ||
|
|
||
| await ctx.send(card) | ||
|
|
||
|
|
||
| @app.on_message | ||
| async def handle_message(ctx: ActivityContext[MessageActivity]): | ||
| await ctx.reply(TypingActivityInput()) | ||
| await ctx.send("Welcome to the meetings sample! This app will notify you for meeting events.") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(app.start()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
| # pyright: basic | ||
|
|
||
| from datetime import datetime | ||
|
|
||
| import pytest | ||
| from microsoft_teams.api.activities.event.meeting_end import ( | ||
| MeetingEndEventValue, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| class TestMeetingEndEventValue: | ||
| """Unit tests for MeetingEndEventValue serialization.""" | ||
|
|
||
| def test_deserialization_from_aliased_fields(self): | ||
| """Test that MeetingEndEventValue correctly deserializes from aliased field names""" | ||
| data = { | ||
| "Id": "meeting-123-base64", | ||
| "MeetingType": "Scheduled", | ||
| "JoinUrl": "https://teams.microsoft.com/join/meeting-123", | ||
| "Title": "Sprint Planning Meeting", | ||
| "EndTime": "2024-01-15T15:30:00Z", | ||
| } | ||
|
|
||
| event_value = MeetingEndEventValue.model_validate(data) | ||
| assert event_value.id == "meeting-123-base64" | ||
| assert event_value.meeting_type == "Scheduled" | ||
| assert event_value.join_url == "https://teams.microsoft.com/join/meeting-123" | ||
| assert event_value.title == "Sprint Planning Meeting" | ||
| assert isinstance(event_value.end_time, datetime) | ||
| assert event_value.end_time.year == 2024 | ||
| assert event_value.end_time.month == 1 | ||
| assert event_value.end_time.day == 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| """ | ||
| Copyright (c) Microsoft Corporation. All rights reserved. | ||
| Licensed under the MIT License. | ||
| """ | ||
| # pyright: basic | ||
|
|
||
| from datetime import datetime | ||
|
|
||
| import pytest | ||
| from microsoft_teams.api.activities.event.meeting_start import ( | ||
| MeetingStartEventValue, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| class TestMeetingStartEventValue: | ||
| """Unit tests for MeetingStartEventValue serialization.""" | ||
|
|
||
| def test_deserialization_from_aliased_fields(self): | ||
| """Test that MeetingStartEventValue correctly deserializes from aliased field names""" | ||
| data = { | ||
| "Id": "meeting-123-base64", | ||
| "MeetingType": "Scheduled", | ||
| "JoinUrl": "https://teams.microsoft.com/join/meeting-123", | ||
| "Title": "Sprint Planning Meeting", | ||
| "StartTime": "2024-01-15T14:30:00Z", | ||
| } | ||
|
|
||
| event_value = MeetingStartEventValue.model_validate(data) | ||
|
|
||
| assert event_value.id == "meeting-123-base64" | ||
| assert event_value.meeting_type == "Scheduled" | ||
| assert event_value.join_url == "https://teams.microsoft.com/join/meeting-123" | ||
| assert event_value.title == "Sprint Planning Meeting" | ||
| assert isinstance(event_value.start_time, datetime) | ||
| assert event_value.start_time.year == 2024 | ||
| assert event_value.start_time.month == 1 | ||
| assert event_value.start_time.day == 15 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.