Skip to main content
Connectors

GitHub

Mention an agent in a GitHub issue or pull request comment.

GitHubRoute/github/webhookAgent Actorreceive, replywebhookreceive()issues.createComment

Quickstart

Create a bot account and token

Create a GitHub account for the agent, or use your own, and a fine-grained personal access token for the repository with the Issues permission set to read and write. It covers comments on pull requests too.

Add the route

npm add @rivet-dev/pi rivetkit hono @octokit/rest @octokit/webhooks-methods

Run the server with any runtime that serves a fetch handler, for example npx srvx --import tsx server.ts. See HTTP Server.

Set the environment

GITHUB_WEBHOOK_SECRET=...
GITHUB_TOKEN=github_pat_...
GITHUB_BOT_LOGIN=my-agent
ANTHROPIC_API_KEY=sk-ant-...

Add the webhook

In the repository’s Settings > Webhooks, add a webhook with the payload URL https://<your-worker>/github/webhook, content type application/json, your secret, and the Issue comments event. Comment @my-agent on an issue or pull request.

How it works

  • The route verifies GitHub’s X-Hub-Signature-256 signature against the raw body.
  • Each issue or pull request gets its own agent, keyed by owner, repository, and number. Every mention in the thread continues the same session.
  • The route only answers new comments that mention the bot, and never the bot’s own comments, so replies do not loop.
  • GitHub times out a delivery after ten seconds, so the route only hands the comment to the agent’s receive action and returns. The receive action adds the message to the agent’s queue and schedules drain, which prompts the agent with the oldest message and posts the answer as a comment with Octokit. A message that arrives while the agent is answering waits in the queue. The queue is saved with the agent, so replies still run if the request that delivered a message goes away.

Configure

VariablePurpose
GITHUB_WEBHOOK_SECRETRequired. Verifies that deliveries come from GitHub.
GITHUB_TOKENRequired. Posts replies as the bot account.
GITHUB_BOT_LOGINRequired. The bot’s username. Comments that mention it start a reply.
ANTHROPIC_API_KEYRequired. The agent’s model key. For another provider, change model and set its key instead, such as OPENAI_API_KEY or OPENROUTER_API_KEY. See LLM API Keys.

Supported events

GitHub eventWebhook pathWhat the route does
issue_comment, created/github/webhookHands the comment to the issue’s agent, which replies with a comment. Covers pull request conversations too.