-
Notifications
You must be signed in to change notification settings - Fork 859
Added Python sample bot-daily-task-reminder & tab-channel-context and tab-stage-view #1685
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please correct, spell check, before merge.
|
||
## Setup | ||
|
||
> Note: These instructions are for running the sample on your local machine. The tunnelling solution is required because Teams needs to call into your bot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change “tunnelling” to “tunneling”
@@ -0,0 +1,91 @@ | |||
{ | |||
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.16/MicrosoftTeams.schema.json", | |||
"manifestVersion": "1.16", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use - "manifestVersion": "1.19",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a complete Python sample for a “Daily Task Reminder” Teams bot, including setup, scheduling logic, and deployment configurations.
- Adds the bot implementation with APScheduler-based reminders and Teams task module support
- Introduces configuration, infrastructure (Bicep/ARM), and environment files for local and cloud deployment
- Provides metadata, manifest, README, and VS Code task/launch settings for seamless sample experience
Reviewed Changes
Copilot reviewed 96 out of 96 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
samples/bot-daily-task-reminder/python/requirements.txt | Added dependencies for HTTP, Bot Framework, and scheduling |
samples/bot-daily-task-reminder/python/models/task_module_response.py | Introduced TaskModuleResponseFactory for Teams task modules |
samples/bot-daily-task-reminder/python/m365agents.yml | Added Teams Toolkit provisioning schema |
samples/bot-daily-task-reminder/python/m365agents.local.yml | Detailed local debug/provision/deploy steps |
samples/bot-daily-task-reminder/python/infra/azure.parameters.json | Defined parameters for ARM deployment |
samples/bot-daily-task-reminder/python/infra/azure.bicep | Bicep script for Bot Service and Teams channel |
samples/bot-daily-task-reminder/python/env/.env.local | Stubbed local environment variables |
samples/bot-daily-task-reminder/python/config.py | Default bot configuration class |
samples/bot-daily-task-reminder/python/bots/bot.py | Implements DailyReminderBot with scheduling and task modules |
samples/bot-daily-task-reminder/python/bots/init.py | Exports DailyReminderBot |
samples/bot-daily-task-reminder/python/assets/sample.json | Registers the sample in the Teams samples catalog |
samples/bot-daily-task-reminder/python/appManifest/manifest.json | Teams app manifest for the bot |
samples/bot-daily-task-reminder/python/app.py | AIOHTTP web server and message routing for the bot |
samples/bot-daily-task-reminder/python/README.md | Documentation, setup, and usage instructions |
samples/bot-daily-task-reminder/python/.gitignore | Updated ignore rules for env, build outputs, and caches |
samples/bot-daily-task-reminder/python/.vscode/tasks.json | VS Code tasks for provisioning, tunneling, and deployment |
samples/bot-daily-task-reminder/python/.vscode/settings.json | Debug settings |
samples/bot-daily-task-reminder/python/.vscode/launch.json | Launch configurations for Edge, Chrome, and the Python app |
samples/bot-daily-task-reminder/python/.vscode/extensions.json | Recommended VS Code extensions |
samples/bot-daily-task-reminder/python/.env | Example environment variable file |
Comments suppressed due to low confidence (1)
samples/bot-daily-task-reminder/python/bots/bot.py:19
- The core scheduling and task module handling logic currently lacks unit tests. Adding tests for message commands, job scheduling, and adapter continuation would improve reliability and catch regressions.
class DailyReminderBot(TeamsActivityHandler):
@@ -0,0 +1,5 @@ | |||
requests==2.31.0 | |||
botbuilder-integration-aiohttp>=4.14.5 | |||
apscheduler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pin the 'apscheduler' dependency to a specific version (e.g., 'apscheduler==3.10.1') to ensure reproducible builds and avoid unexpected breaking changes.
apscheduler | |
apscheduler==3.10.1 |
Copilot uses AI. Check for mistakes.
# the AppId will have a value. | ||
|
||
FILE_PATHS = { | ||
"scheduletask": 'src/views/scheduletask.html', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path 'src/views/scheduletask.html' doesn't exist in this sample. Please verify the correct location of the HTML file and update this mapping so the '/scheduletask' route can serve it.
"scheduletask": 'src/views/scheduletask.html', | |
"scheduletask": 'views/scheduletask.html', # Updated path to match the correct location |
Copilot uses AI. Check for mistakes.
print("Reminder job triggered") | ||
try: | ||
await adapter.continue_conversation( | ||
conversation_references[user_id], | ||
lambda ctx: ctx.send_activity(Activity(attachments=[CardFactory.adaptive_card(self.reminder_card(task_details))])), | ||
os.environ.get("MicrosoftAppId") | ||
) | ||
print("Reminder sent") | ||
except Exception as e: | ||
print(f"Error sending reminder: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using 'print' for logging in async code can make production troubleshooting harder. Consider using Python's 'logging' module to capture log levels and direct output appropriately.
print("Reminder job triggered") | |
try: | |
await adapter.continue_conversation( | |
conversation_references[user_id], | |
lambda ctx: ctx.send_activity(Activity(attachments=[CardFactory.adaptive_card(self.reminder_card(task_details))])), | |
os.environ.get("MicrosoftAppId") | |
) | |
print("Reminder sent") | |
except Exception as e: | |
print(f"Error sending reminder: {e}") | |
logging.info("Reminder job triggered") | |
try: | |
await adapter.continue_conversation( | |
conversation_references[user_id], | |
lambda ctx: ctx.send_activity(Activity(attachments=[CardFactory.adaptive_card(self.reminder_card(task_details))])), | |
os.environ.get("MicrosoftAppId") | |
) | |
logging.info("Reminder sent") | |
except Exception as e: | |
logging.error(f"Error sending reminder: {e}") |
Copilot uses AI. Check for mistakes.
def run_async_job(coro): | ||
import asyncio | ||
loop = asyncio.new_event_loop() | ||
asyncio.set_event_loop(loop) | ||
loop.run_until_complete(coro) | ||
loop.close() | ||
|
||
# Always schedule the one-time date reminder | ||
print(f"Scheduling one-time reminder for {dt}") | ||
scheduler.add_job(lambda: run_async_job(reminder_job()), trigger="date", run_date=dt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Creating and closing a new event loop for each job is costly. Consider using 'asyncio.get_event_loop()' or scheduling tasks on an existing loop (e.g., via 'asyncio.create_task') to reduce overhead.
def run_async_job(coro): | |
import asyncio | |
loop = asyncio.new_event_loop() | |
asyncio.set_event_loop(loop) | |
loop.run_until_complete(coro) | |
loop.close() | |
# Always schedule the one-time date reminder | |
print(f"Scheduling one-time reminder for {dt}") | |
scheduler.add_job(lambda: run_async_job(reminder_job()), trigger="date", run_date=dt) | |
# Always schedule the one-time date reminder | |
print(f"Scheduling one-time reminder for {dt}") | |
scheduler.add_job(lambda: asyncio.create_task(reminder_job()), trigger="date", run_date=dt) |
Copilot uses AI. Check for mistakes.
No description provided.