Posts daily GitHub Copilot per-user usage metrics to a Slack channel via a scheduled GitHub Actions workflow.
For each user with activity on the previous day:
- Interaction count (prompts sent to Copilot)
- Code generations and acceptances
- Lines of code added
- Activity type (chat, agent, CLI, completions)
- Aggregate model usage breakdown
- CLI token consumption (if applicable)
Create a fine-grained PAT scoped to the shadow-robot organization with:
- "Organization Copilot metrics" permission: Read
Alternatively, a classic PAT with read:org scope works.
- Go to https://api.slack.com/apps and create a new app (or use an existing one)
- Enable Incoming Webhooks
- Add a webhook to the channel where you want reports posted
- Copy the webhook URL
In the GitHub repo hosting this code, go to Settings → Secrets and variables → Actions and add:
| Secret | Value |
|---|---|
COPILOT_METRICS_TOKEN |
Your GitHub PAT from step 1 |
SLACK_WEBHOOK_URL |
Your Slack webhook URL from step 2 |
In your org settings, ensure Copilot Usage Metrics API is enabled:
- Go to your org → Settings → Copilot → Policies
- Enable "Copilot usage metrics"
Push this repo to GitHub. The workflow runs daily at 08:00 UTC. You can also trigger it manually from the Actions tab (with an optional day override).
export GH_TOKEN="ghp_..."
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."
export GITHUB_ORG="shadow-robot"
# export REPORT_DAY="2026-05-05" # optional override
pip install -r requirements.txt
python copilot_usage.py- The API requires the "Copilot usage metrics" policy to be enabled at the org level
- Data is available starting from the day after the policy is enabled
- Reports for a given day are processed overnight; yesterday's data is typically available by morning
- Only org owners (admins) can access these metrics via the API