Skip to main content

GitHub adapter for chat-py

Project description

chat-adapter-github

GitHub adapter for chat-py. Python port of upstream packages/adapter-github.

Handles issue_comment and pull_request_review_comment webhooks; supports PAT, single-tenant GitHub App, and multi-tenant GitHub App auth.

Install

uv add chat-py chat-py-adapter-github chat-py-adapter-state-pg

Auth / config

Three discriminated config variants:

Mode Required fields Env var fallbacks
PAT (personal access token) token GITHUB_TOKEN
Single-tenant App appId + installationId + privateKey GITHUB_APP_ID, GITHUB_INSTALLATION_ID, GITHUB_APP_PRIVATE_KEY
Multi-tenant App appId + privateKey GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY

All variants additionally accept: webhookSecret (required for signature verify), botUserId, apiUrl, logger, userName.

Minimal example

from chat import Chat
from chat_adapter_github import create_github_adapter
from chat_adapter_state_pg import create_postgres_state

bot = Chat(
    user_name="mybot",
    adapters={"github": create_github_adapter(
        token="ghp_...",             # PAT mode
        webhookSecret="...",
    )},
    state=create_postgres_state(url="postgres://localhost/chat"),
)


@bot.on_new_mention
async def respond(thread, message):
    await thread.post("On it.")

Mount bot.handle_webhook("github", body, headers) under /api/webhooks/github. The handler verifies X-Hub-Signature-256 via verify_github_signature.

Thread ID

GitHub thread IDs encode {owner}/{repo}#{issue_or_pr_number}, optionally with a comment ID for review threads.

Features

  • HMAC-SHA256 webhook signature verify (verify_github_signature)
  • GFM markdown rendering via GitHubFormatConverter
  • card_to_github_markdown / card_to_plain_text fallbacks (no native card support)
  • Reactions (on_reaction) for issue comments and PR review comments

Parity notes

  • No card or streaming support — GitHub comments are markdown-only. Cards degrade to GFM via card_to_github_markdown.
  • Error wrapping (handle_github_error) maps GitHub REST errors to the shared AdapterError hierarchy.

Test

uv run pytest packages/chat-adapter-github

# Live
GITHUB_TOKEN=... uv run pytest packages/chat-integration-tests -k github

Upstream

https://github.com/vercel/chat/tree/main/packages/adapter-github

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chat_py_adapter_github-0.1.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file chat_py_adapter_github-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chat_py_adapter_github-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chat_py_adapter_github-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa15e472d8612eb163786b3c83c4df9e0316b47617311b9696d677ad4b0c5a90
MD5 22818473640e1b478d6f35ae2c7d5f14
BLAKE2b-256 900c613958da8df1f4a665657a48b57d7407a4c17e6092254354d5d73a26f00e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page