Automate GitHub issue and pull request management using Motia’s type-safe, event-driven steps and OpenAI-assisted classification.
- 🤖 Classifies issues and PRs using LLMs
- 🏷️ Applies labels from classification (type/impact/areas)
- 👥 Suggests reviewers and assignees
- ✅ Monitors CI test status and comments outcomes
- 📝 Writes friendly, contextual comments on issues/PRs
- Step-based architecture: Each unit of work is a small, testable step.
- Events over glue code: Steps communicate via emitted topics (e.g.,
github.pr.opened → github.pr.classified). - Type-safe handlers:
Handlers['Step Name']gives compile-time safety for inputs/outputs and emitted events. - Runtime validation: Zod schemas validate incoming payloads for API steps.
- Workbench: Visualize and simulate the entire flow without writing extra scripts.
-
PR flow:
PR Webhook Handler(/api/github/pr-webhook)PR Classifier→ emitsgithub.pr.classifiedPR Label Assigner→ applies labelsPR Test Monitor→ watches check runs and emitsgithub.pr.tests-completedPR Reviewer Assigner→ suggests reviewers and comments
-
Issue flow:
GitHub Webhook Handler(/api/github/webhook)New Issue Handler→ initial triageIssue Classifier→ emitsgithub.issue.classifiedLabel Assigner→ applies labelsAssignee Selector→ assigns users and commentsIssue Update/Closure→ posts updates and archives
- Issues:
POST /api/github/webhook - PRs:
POST /api/github/pr-webhook
Example cURL (PR opened):
curl -X POST http://localhost:3000/api/github/pr-webhook \
-H 'Content-Type: application/json' \
-d '{
"action": "opened",
"pull_request": {
"number": 123,
"title": "Add new feature",
"body": "This PR adds a new feature",
"state": "open",
"labels": [],
"user": { "login": "testuser" },
"base": { "ref": "main" },
"head": { "ref": "feature-branch", "sha": "abc123" }
},
"repository": { "owner": { "login": "motia" }, "name": "motia-examples" }
}'- Node.js 18+
- GitHub personal access token
- OpenAI API key
- Install dependencies
npm install- Environment
cp .env.example .envAdd the following to .env:
GITHUB_TOKEN=your_github_token_here
OPENAI_API_KEY=your_openai_api_keyStart workbench and API server:
npm run devDebug (verbose):
npm run dev:debug- Open the workbench UI printed in the console
- Use UI simulators:
steps/issue-triage/test-github-issue.step.tsx→ simulate issue webhookssteps/pr-classifier/test-pr-webhook.step.tsx→ simulate PR webhooks
- Watch downstream steps execute and events propagate
Unit tests use Jest with mocked OpenAI and GitHub clients.
- Run all tests
npm test- Watch mode
npm run test:watch- Coverage
npm run test:coverageWhat’s covered:
- Webhook parsing and event emission
- Classification calls and error paths
- Label/assignee/reviewer actions
- Test monitoring and result comments
- Lint
npm run lint- Fix
npm run lint:fix- Format
npm run format├── services/
│ ├── github/ # Octokit wrapper
│ └── openai/ # OpenAI helper client
├── steps/
│ ├── issue-triage/ # Issue workflow steps
│ └── pr-classifier/# PR workflow steps
├── __tests__/ # Jest unit tests
└── motia-workbench.json
- Handlers use
Handlers['Step Name']to bind input/output types - API steps use Zod for
bodySchemaandresponseSchema - Emitted event payloads are validated at compile-time against
types.d.ts
You can deploy your GitHub Integration Workflow to Motia Cloud using either the CLI or the web interface.
Deploy with a specific version:
motia cloud deploy --api-key your-api-key-here --version-name 1.0.0Deploy to a specific environment with environment variables:
motia cloud deploy --api-key your-api-key-here \
--version-name 1.0.0 \
--env-file .env.production \
--environment-id env-idFor a visual deployment experience, use the Motia Cloud web interface:
- Have your local project running (
npm run dev) - Go to Import from Workbench on Motia Cloud
- Select the port your local project is running on (default: 3000)
- Choose the project and environment name
- Add environment variables:
GITHUB_TOKENOPENAI_API_KEYGITHUB_WEBHOOK_SECRET(optional)
- Click Deploy and watch the magic happen! ✨
For detailed instructions, see the Motia Cloud Deployment Guide.
MIT