KlangDocs
Open Klang

Webhooks

GitHub

Point a GitHub repository at a Klang webhook and its pushes, pull requests, issues and releases show up in a channel as embeds, the way Discord does it.

Set it up

  1. Create a webhook in Klang for the channel and copy its URL (see Create a webhook).

  2. In GitHub, open the repository’s Settings › Webhooks › Add webhook. For every repository of an organization, use the organization’s Settings › Webhooks instead.

  3. In Payload URL, paste the Klang URL with /github at the end:

    URL
    https://api.klang.gg/api/webhooks/{webhook.id}/{webhook.token}/github
  4. In Content type, choose application/json. GitHub’s default, application/x-www-form-urlencoded, gets a 400 that says which one to choose.

  5. Leave Secret empty: Klang doesn’t check it (see Security).

  6. Choose the events: Send me everything or the ones you want. Klang posts the ones in the table below and accepts the rest without posting anything.

  7. Select Add webhook. GitHub sends a ping at once, and it shows up in the channel.

Supported events

Event (X-GitHub-Event) What shows up in the channel
push The commits pushed, up to 5, with their messages.
pull_request A pull request opened, closed, merged or reopened.
issues Activity on an issue.
issue_comment A comment on an issue or a pull request.
release A release published.
create, delete A branch or a tag created or deleted.
star, watch Someone starred the repository.
fork Someone forked the repository.
ping GitHub’s test message, sent when you add the webhook.

Every other event is accepted with a 204 and nothing is posted, so turning on more events in GitHub doesn’t break anything.

Security

GitHub can sign each delivery with a secret (X-Hub-Signature-256), but Klang doesn’t check that signature: the token in the URL already authorizes, as with Discord. That makes the Payload URL the secret. If it leaks, regenerate the token and paste the new URL, with /github at the end, in GitHub.

When something doesn’t show up

GitHub keeps every delivery and Klang’s answer under the webhook’s Recent Deliveries:

  • 204: Klang took it. If nothing was posted, the event isn’t one of the supported ones.
  • 400: the content type isn’t application/json. Change it, then select Redeliver.
  • 404: the URL is wrong, or the token was regenerated or the webhook deleted. Copy the URL again from Klang.
  • 429: over the rate limit, 5 requests every 2 seconds per webhook. A very busy repository may hit it: send only the events you need.