Skip to content

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

YugalPradhan31
Copy link
Contributor

No description provided.

@YugalPradhan31 YugalPradhan31 changed the title Added bot-daily-task-reminder sample Added Python sample bot-daily-task-reminder Jun 3, 2025
@Harikrishnan-MSFT Harikrishnan-MSFT changed the title Added Python sample bot-daily-task-reminder Added Python sample bot-daily-task-reminder & tab-channel-context and tab-stage-view Jun 18, 2025
Copy link
Collaborator

@Pawank-MSFT Pawank-MSFT left a 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change “tunnelling” to “tunneling”

Copilot

This comment was marked as outdated.

@@ -0,0 +1,91 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
"manifestVersion": "1.16",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use - "manifestVersion": "1.19",

Copy link
Contributor

@Copilot Copilot AI left a 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
Copy link
Preview

Copilot AI Jun 18, 2025

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.

Suggested change
apscheduler
apscheduler==3.10.1

Copilot uses AI. Check for mistakes.

# the AppId will have a value.

FILE_PATHS = {
"scheduletask": 'src/views/scheduletask.html',
Copy link
Preview

Copilot AI Jun 18, 2025

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.

Suggested change
"scheduletask": 'src/views/scheduletask.html',
"scheduletask": 'views/scheduletask.html', # Updated path to match the correct location

Copilot uses AI. Check for mistakes.

Comment on lines 77 to 86
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}")
Copy link
Preview

Copilot AI Jun 18, 2025

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.

Suggested change
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.

Comment on lines 88 to 97
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)
Copy link
Preview

Copilot AI Jun 18, 2025

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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants