Canvas LMS submission and comment monitoring
- A Canvas LMS access token (from your Canvas account settings)
Setup uv:
uv syncCreate a token file in the project root and paste your Canvas access token, or:
echo "your-canvas-api-token" > tokenBefore running the main script, you need to set constant for groups and fetch students group mapping:
# For example "https://canvas.tue.nl/courses/32560/groups#tab-25446"
GROUP = 25446uv run fetch_groups.pyThen, edit the constants in main.py:
API = "https://canvas.tue.nl"
COURSE_ID = 32560
ASSIGNMENT_ID = 146386Then, run the script:
uv run main.pynotify_course_comments.py monitors a single course and send only student-authored submission comments to a Teams channel via Teams Workflow Webhook alerts.
It uses student_groups.json to identify student authors, and keeps de-duplication state in a JSON file.
Set required environment variables:
export CANVAS_COURSE_ID="32560"
export TEAMS_WEBHOOK_URL="https://..."
export CANVAS_TOKEN="your-canvas-token"Optional variables:
export CANVAS_API_BASE="https://canvas.tue.nl" # default: https://canvas.tue.nl
export STUDENT_GROUPS_FILE="student_groups.json" # default: student_groups.json
export STATE_FILE="state/course_comment_dedupe.json" # default: state/course_comment_dedupe.json
export FIRST_RUN_BEHAVIOR="baseline" # baseline | notify
export DRY_RUN="false" # true|false (no Teams post, no state writes)
export TEAMS_WEBHOOK_MODE="auto" # auto | adaptivecard | messagecardRun:
uv run notify_course_comments.pyFIRST_RUN_BEHAVIOR=baseline (default) stores existing comments in state without posting them, then posts only future comments.
Safe local verification:
DRY_RUN=true uv run notify_course_comments.pyWorkflow file: .github/workflows/course-comments-to-teams.yml
-
Add repository secrets:
CANVAS_TOKENTEAMS_WEBHOOK_URL
-
Add repository variable:
CANVAS_COURSE_ID
-
Optional repository variables:
CANVAS_API_BASE(defaults tohttps://canvas.tue.nlif unset)FIRST_RUN_BEHAVIOR(baselineornotify, defaults tobaseline)STATE_BRANCH(defaults todefaultif you keep workflow as-is)
-
Ensure the state branch exists (only needed if you use a non-default branch for state):
git switch -c default
git push -u origin default
git switch -The workflow runs daily and on manual dispatch, then commits only the de-dup state file (state/course_comment_dedupe.json) with [skip ci].