Skip to content

Add GitHub issue/PR comments as a second input channel#3

Open
slacki-ai wants to merge 1 commit intomainfrom
feature/github-webhook-channel
Open

Add GitHub issue/PR comments as a second input channel#3
slacki-ai wants to merge 1 commit intomainfrom
feature/github-webhook-channel

Conversation

@slacki-ai
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a lightweight HTTP webhook server that starts inside the existing Claudex process alongside the Slack Socket Mode connection — no separate service or process needed
  • When @claudex is mentioned in a GitHub issue or PR comment, it routes through the same createSession / resumeSession infrastructure already used for Slack
  • Sessions are keyed by gh:{owner/repo}#{issue_number} in the existing store, so Claude retains context across the full issue/PR thread exactly as it does per Slack thread
  • Responses are posted back as GitHub comments via the REST API
  • Entirely opt-in: the GitHub server only starts if GITHUB_TOKEN is set

New files

src/github/post.ts — posts a comment to a GitHub issue/PR via the REST API

src/github/handler.ts — the webhook server:

  • Starts an http.Server on GITHUB_WEBHOOK_PORT (default 8080)
  • Verifies X-Hub-Signature-256 (skips if GITHUB_WEBHOOK_SECRET not set, for easy local dev)
  • Filters issue_comment events where the comment body contains GITHUB_BOT_HANDLE (default @claudex)
  • Maps repo + issue_number → session key → createSession / resumeSession
  • Posts the response back as a GitHub comment

Modified files

src/index.ts — conditionally starts the webhook server after the Slack app

README.md — documents new env vars and GitHub App setup steps

New env vars (all optional)

Var Default Purpose
GITHUB_TOKEN Enables the GitHub channel; fine-grained PAT with issues: write
GITHUB_WEBHOOK_SECRET Shared secret for X-Hub-Signature-256 verification
GITHUB_BOT_HANDLE @claudex Mention string Claude watches for
GITHUB_WEBHOOK_PORT 8080 HTTP port for the webhook server

Test plan

  • Set GITHUB_TOKEN + GITHUB_WEBHOOK_SECRET, restart Claudex — confirm ⚡ GitHub webhook server listening on port 8080 in logs
  • Leave GITHUB_TOKEN unset — confirm GitHub webhook server disabled log, Slack still works
  • Send a test webhook payload (e.g. via gh CLI or curl) — confirm Claude responds as a comment
  • Reply in the same issue — confirm session is resumed (same sessionId in logs)
  • Forge an invalid signature — confirm 401 Unauthorized

🤖 Generated with Claude Code

When GITHUB_TOKEN is set, Claudex now starts a lightweight HTTP webhook
server (default port 8080) alongside the existing Slack Socket Mode
connection. Mentioning @claudex in a GitHub issue or PR comment routes
the message through the same Claude Code session infrastructure used for
Slack — no separate service required.

Sessions are keyed by `gh:{owner/repo}#{issue_number}` in the existing
store, so context persists across the full issue/PR thread exactly as it
does per Slack thread. Responses are posted back as GitHub comments via
the REST API.

New files:
- src/github/handler.ts  webhook server, signature verification, session routing
- src/github/post.ts     post comments back to GitHub

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant