# React to GitHub events, set up from your AI assistant

Source: https://clickruntime.com/use-cases/github-webhooks

> Ask for what should happen when an issue is opened, a pull request is merged or a release is published. ClickRuntime gives you the webhook URL, checks GitHub's signature and runs the code.

## Can ChatGPT or Claude react to GitHub events?

An assistant can read a repo while you chat, but it can't be notified when an issue is opened. With ClickRuntime connected, it creates an automation with a trigger link that you add as a GitHub webhook. GitHub posts each event there, ClickRuntime checks the X-Hub-Signature-256 header, and the script labels, comments, notifies or updates whatever you asked for.

### Why the assistant can't do this on its own

- GitHub webhooks need a public HTTPS URL that's always up. Assistants don't have one.
- The script needs a GitHub token kept outside the chat. ClickRuntime stores it as a secret.
- Actions workflows can react to events too, but they live in the repo and need YAML. Here you describe the result and it runs across repos without editing any of them.

## Set it up from your AI assistant

Prompt to copy:

> Create a ClickRuntime automation: when a new issue is opened in acme/app, read the title and body and add one label: bug, feature or question. Check GitHub's webhook signature.

1. **Connect ClickRuntime to your assistant.** Add ClickRuntime as a connector (MCP server) in ChatGPT, Claude, Cursor or another MCP client, using https://clickruntime.com/api/mcp. You sign in with Google or email; there is no API key to copy. This is done once per assistant.
2. **Paste the prompt.** Start a new chat and paste: “Create a ClickRuntime automation: when a new issue is opened in acme/app, read the title and body and add one label: bug, feature or question. Check GitHub's webhook signature.” Change the details (times, channels, addresses) to yours.
3. **Read the draft.** The assistant restates what will happen, asks for anything missing, such as your timezone or which channel to post to, and saves a draft automation. A draft never runs on its own, so nothing happens until you agree.
4. **Connect accounts and save keys.** The assistant asks you to save a fine-grained GitHub token with Issues read and write on the repo as GITHUB_TOKEN in the ClickRuntime dashboard. It can register the webhook for you with that token, or give you the trigger link and a secret to add under the repo's Settings → Webhooks (content type JSON, Issues events).
5. **Test it.** GitHub sends a ping when the webhook is added; then open a test issue. The assistant checks the stored event, the signature result and that the label was added.
6. **Turn it on.** The assistant tells you what will run, when, and which services it will contact, then asks your permission to turn it on. From then on it runs on ClickRuntime's servers, and you can close the chat.
7. **Check it in the ClickRuntime dashboard.** Incoming events are listed with the GitHub event type, the signature result and the run each started. The run log shows which label was chosen for which issue. Failed runs can be replayed after a fix.

Connector setup for each assistant: https://clickruntime.com/assistants

## What the assistant writes

`label_new_issues.py`

```python
from clickruntime import on_event, credentials, http, ai, log

LABELS = ["bug", "feature", "question"]

@on_event
def handle(event):
    if not event.is_verified:
        return {"skipped": "bad signature"}
    if event.header("X-GitHub-Event") != "issues" or event.json.get("action") != "opened":
        return {"skipped": "not a new issue"}

    issue = event.json["issue"]
    repo = event.json["repository"]["full_name"]
    text = f"{issue['title']}\n\n{(issue.get('body') or '')[:2000]}"
    try:
        label = ai.generate(text, system="Answer with one word: bug, feature or question.", max_output_tokens=5).text.strip().lower()
    except ai.AIError:
        label = "bug" if "error" in text.lower() or "crash" in text.lower() else "question"
    if label not in LABELS:
        label = "question"

    token = credentials.secret("GITHUB_TOKEN")
    http.post(
        f"https://api.github.com/repos/{repo}/issues/{issue['number']}/labels",
        headers={"Authorization": "Bearer " + token, "Accept": "application/vnd.github+json"},
        json={"labels": [label]},
    ).raise_for_status()
    log.info("Labelled", {"issue": issue["number"], "label": label})
    return {"issue": issue["number"], "label": label}
```

- The trigger link's GitHub signature check runs before the script, so `event.is_verified` is true only for genuine GitHub deliveries.
- AI picks the label from the issue text. If AI is unavailable, a keyword rule keeps the run working.
- The same pattern works for pull_request, release, push or star events: the assistant changes the event filter and what the script does.

## Trigger link, not a schedule

Use the trigger link for anything that should happen right after a GitHub event.

Use a schedule for checks GitHub doesn't send events for, such as pull requests with no review for three days.

## Limits

- Each delivery is one run; subscribe the webhook only to the events you need.
- The GitHub token's permissions limit what the script can do. Use a fine-grained token scoped to the repos involved.
- The AI reads text only; images in issues are not sent.

## Troubleshooting

### GitHub shows the ping failed.

Check the payload URL is the trigger link and the content type is application/json. The ClickRuntime dashboard lists every delivery that arrived.

### Labels aren't added (403 or 404).

The token can't write issues on that repo. Create a fine-grained token with Issues read and write on it and save it again as GITHUB_TOKEN.

### Signature checks fail.

The secret in GitHub's webhook settings differs from the one in the trigger link settings. Set the same value in both and redeliver from GitHub.

## Related

- [GitHub automations](https://clickruntime.com/apps/github)
- [Slack automations](https://clickruntime.com/apps/slack)
- [Linear automations](https://clickruntime.com/apps/linear)
- [Jira automations](https://clickruntime.com/apps/jira)
- [github-issue-triage](https://clickruntime.com/templates/github-issue-triage)
- [ai-review-of-new-pull-requests](https://clickruntime.com/templates/ai-review-of-new-pull-requests)
- [new-releases-of-watched-github-repos](https://clickruntime.com/templates/new-releases-of-watched-github-repos)
- [Webhook automation](https://clickruntime.com/use-cases/webhook-automation)
- [Stale pull request reminders](https://clickruntime.com/use-cases/stale-pull-request-reminders)
- [AI triage and summaries](https://clickruntime.com/use-cases/ai-classify-and-summarise)
- [GitHub Actions cron alternative](https://clickruntime.com/alternatives/github-actions-cron)
- [Pipedream alternative](https://clickruntime.com/alternatives/pipedream)
- [Docs: trigger-links](https://clickruntime.com/docs/trigger-links)
- [Docs: connections-and-secrets](https://clickruntime.com/docs/connections-and-secrets)

## Extend it: what you can add next

The first version is rarely the last. Because the automation is a Python script with memory, AI and any API available, you grow it by asking your assistant for the change. Each change is a new version, and a failed deploy never replaces the working one.

- **Comment asking for missing steps to reproduce on bug reports** (Built-in AI)
  Prompt: "Change my issue labelling automation so that when a bug report has no steps to reproduce, it comments asking for them politely."
- **Post new bugs to #engineering in Slack** (Any app or API)
  Prompt: "Add to my issue labelling automation: when an issue is labelled bug, post its title and link to #engineering in Slack."
- **Copy bugs to Linear with the same title and link** (Any app or API)
  Prompt: "Add to my issue labelling automation: create a Linear issue in the Platform team for each new bug, linking back to GitHub."
- **Spot repeat reports by remembering recent issue titles** (Memory between runs)
  Prompt: "Change my issue labelling automation so it remembers the last 200 issue titles and comments with a link when a new issue looks like a repeat."
- **A Monday digest of last week's issues by label** (Schedules)
  Prompt: "Add to my issue labelling automation: every Monday at 9, email me how many issues were opened last week per label, with links to the bugs."
- **Handle pull requests too: welcome first-time contributors** (Multi-step logic)
  Prompt: "Change my issue labelling automation so it also handles new pull requests, and comments a thank-you on a contributor's first pull request."
- **Listen to several repos through the same trigger link** (Trigger links)
  Prompt: "Change my issue labelling automation so it works for acme/app, acme/api and acme/docs, using a different label set for docs."

## Questions

### Can ChatGPT respond to GitHub webhooks?

With ClickRuntime connected, yes. ChatGPT sets up the automation and its trigger link; GitHub sends events there and the script runs on ClickRuntime's servers.

### How is this different from GitHub Actions?

Actions run inside one repo from YAML files. A ClickRuntime automation is described in chat, can span repos and other apps, keeps state between runs and has built-in AI. For CI and builds, Actions is the better fit.

### Is GitHub's signature checked?

Yes. Set the webhook secret in the trigger link's signature settings and only deliveries signed with it reach the script.

### Can it register the webhook for me?

Yes, when you've saved a GitHub token with permission to manage the repo's webhooks. Otherwise the assistant gives you the URL and secret to add yourself.

### Does it work with GitHub organisations?

Yes. An organisation webhook sends events from all its repos to one trigger link, and the script reads the repository from each event.
