Connecting to GitHub
This guide explains how to connect mOperator to GitHub so the bot can fetch commits, releases, and other repository data.
Prerequisites
- Access to a GitHub repository
- Permission to create Personal Access Tokens (or have someone with access create one for you)
Step 1: Create a Personal Access Token
- Go to github.com and log in
- Click your profile picture in the top-right
- Go to "Settings"
- In the left sidebar, click "Developer Settings"
- Click "Personal access tokens" → "Fine-grained tokens"
- Click "Generate new token"
- Fill in the form:
- Token name:
mOperator - Expiration: Choose "90 days" (you'll regenerate it periodically)
- Resource owner: Your GitHub account or organization
- Repository access: Select "Only select repositories" and choose your repo
- Under "Repository permissions", set:
- Contents: Read-only (we only read commits and releases)
- Click "Generate token"
- Copy the token (you won't see it again) — it starts with
github_pat_
Step 2: Get Your Repository Name
You need the repository in owner/repo format:
- Owner: Your username or organization name
- Repo: The repository name
For example: acme/marketing-site or vercel/next.js
Step 3: Add to Environment
Add these to your .env.local:
GITHUB_TOKEN=github_pat_xxxxxxxxxxxxx
GITHUB_REPO=owner/repo
- Replace:
github_pat_xxxxxxxxxxxxx with your actual tokenowner/repo with your actual GitHub path
Step 4: Test the Connection
Restart your app:
npm run dev
Test in Slack:
@mOperator what shipped this week?
or
@mOperator show me commits since Monday
If it works, you'll see recent commits listed with messages and authors.
What mOperator Can Do With GitHub
Query Commits
@mOperator latest commits
→ Shows recent commits with authors and messages
@mOperator what changed this week
→ Lists commits from the past 7 days
@mOperator commits from April 1 to April 15
→ Commits in a specific date range
Use Cases
- Release notes: Query commits since the last release
- Status updates: See what the team shipped recently
- Code reviews: Check what changes went in this sprint
Troubleshooting
"Invalid token"
- Make sure you copied the entire token (starts with `github_pat_`)
- Verify it's a fine-grained token (not a classic token)
- Check the token hasn't expired in GitHub settings
"Repository not found"
- Verify the format is `owner/repo` (case-sensitive)
- Check the repository is public or you have access to it
- Try a simple query: `@mOperator show commits` (no date filters)
"Permission denied"
- The token needs "Contents: Read-only" permission
- Make sure the token's repository access includes your target repo
- Regenerate the token if needed
"Bot doesn't respond to GitHub queries"
- Check both `GITHUB_TOKEN` and `GITHUB_REPO` are set
- Restart the app after changing env vars
- Check app logs for error details
Token Expiration and Renewal
Fine-grained tokens expire after 90 days. When your token expires:
- Go to GitHub → Settings → Developer Settings → Personal access tokens
- Regenerate the token
- Copy the new token
- Update
.env.local with the new token - Restart your app
Limiting Commit History
By default, mOperator fetches the last 30 days of commits. To change this:
- Edit
GITHUB_REPO value (this is currently the main limit) - Or contact the development team to customize the fetch window
Next Steps
- Test a few queries to get comfortable with commit searches
- (Optional) Set up Linear integration to link commits to issues
- (Optional) Set up Salesforce integration for marketing data alongside code changes