Samples
To start a new Kit from a template instead, run ketvia kits create <slug> --template tools|webhook|events; see the
CLI. The webhook template matches the first sample below and the events template is the starting point for
the second.
ci-webhook: CI notifications
Section titled “ci-webhook: CI notifications”ci-webhook (in samples/ci-webhook) is the smallest possible Kit: an incoming webhook only, with no backend, no
tokens and no events. It posts build results (status, repository, branch, commit, duration and a link to the run) as
Blocks, using postToWebhook and the Blocks builders of @ketvia/kit.
Manifest
Section titled “Manifest”{ "schemaVersion": 1, "slug": "acme-ci-notify", "version": "0.1.0", "displayName": { "en": "Acme CI" }, "description": { "en": "Posts build results to a channel." }, "developer": { "name": "Acme Inc.", "url": "https://acme.dev", "supportEmail": "[email protected]" }, "privacyPolicyUrl": "https://acme.dev/privacy", "bot": { "displayName": { "en": "Acme CI" }, "scopes": ["incoming-webhook"] }, "incomingWebhooks": { "maxPerInstallation": 5 }, "distribution": "private"}Slugs are global, so change slug (and the names) before you create your own copy.
Set up
Section titled “Set up”- In Ketvia, open Admin → Connections, choose Create a private Kit and paste the manifest.
- Install it with Add a Kit, open the Kit’s API access page and create an incoming webhook for the channel the builds should go to (you must be a member of it).
- Copy the URL, which is shown once, into a CI secret named
KETVIA_WEBHOOK_URL. Never commit or print it. If it leaks, revoke the webhook and create a new one.
GitHub Actions
Section titled “GitHub Actions”With the sample’s command (inside the repository that contains it):
- name: Notify Ketvia if: always() env: KETVIA_WEBHOOK_URL: ${{ secrets.KETVIA_WEBHOOK_URL }} run: pnpm --filter @ketvia/sample-ci-webhook notify --status ${{ job.status == 'success' && 'passed' || job.status == 'cancelled' && 'cancelled' || 'failed' }}The command reads GITHUB_REPOSITORY, GITHUB_REF_NAME, GITHUB_SHA, GITHUB_RUN_NUMBER, GITHUB_SERVER_URL,
GITHUB_RUN_ID and GITHUB_ACTOR, which GitHub Actions sets. Options: --status passed|failed|cancelled
(required), --duration <seconds> and --author <name>. It prints posted, or a short error with the HTTP status
and the correlation id, never the URL.
Without any dependency, a plain curl step does the same job:
- name: Notify Ketvia if: always() env: KETVIA_WEBHOOK_URL: ${{ secrets.KETVIA_WEBHOOK_URL }} STATUS: ${{ job.status }} run: | curl -sf -X POST "$KETVIA_WEBHOOK_URL" \ -H 'Content-Type: application/json' \ -d "{\"text\":\"Build #$GITHUB_RUN_NUMBER of $GITHUB_REPOSITORY: $STATUS\", \"blocks\":[{\"type\":\"header\",\"text\":\"Build #$GITHUB_RUN_NUMBER: $STATUS\"}, {\"type\":\"fields\",\"fields\":[{\"label\":\"Branch\",\"value\":\"$GITHUB_REF_NAME\"}]}]}"From code
Section titled “From code”import { notifyBuild } from '@ketvia/sample-ci-webhook';
await notifyBuild(process.env.KETVIA_WEBHOOK_URL ?? '', { repository: 'acme/web', branch: 'main', commit: '3f2a9c1b7e4d', status: 'passed', number: 42, url: 'https://github.com/acme/web/actions/runs/123', durationSeconds: 125,});Responses to expect
Section titled “Responses to expect”404 means the webhook is unknown or revoked; 410 that it was disabled because the channel was archived or the
Kit bot was removed; 429 that you post faster than 1 per second (the sample retries after Retry-After). See
Incoming webhooks.
github-lite: events, a slash command and buttons
Section titled “github-lite: events, a slash command and buttons”github-lite (in samples/github-lite) is a Kit with a backend. It is built on createKitServer from
@ketvia/kit and shows the whole receiving side:
- a (simulated) GitHub
issuesorpull_requestwebhook becomes a card with an Assign to me, a Close (with a confirmation) and an Open on GitHub button, posted to a channel as the Kit bot; - the
/githubslash command answerslist,show owner/repo#12andhelp(Slash commands); - a click arrives as a signed
block_action(Interactivity); the Kit changes the item and answers withreplaceOriginalso the card updates in place; - a
kit.mentionedevent is answered with a help message in the thread, and the SDK dedupes it oneventId.
Everything that leaves the process (the GitHub calls behind the buttons and the post to Ketvia) is injected, so the
tests run without a network. A button value is the owner/repo#number reference; Ketvia reads it from the stored
blocks, so a member cannot send another one.
Manifest
Section titled “Manifest”{ "schemaVersion": 1, "slug": "acme-github-lite", "version": "0.1.0", "displayName": { "en": "GitHub Lite" }, "description": { "en": "Issue and pull request cards with buttons, and a /github command." }, "developer": { "name": "Acme Inc.", "url": "https://acme.dev", "supportEmail": "[email protected]" }, "privacyPolicyUrl": "https://acme.dev/privacy", "bot": { "displayName": { "en": "GitHub Lite" }, "scopes": ["messages:write", "commands"] }, "events": { "url": "https://kit.acme.dev/ketvia/events", "subscribe": ["kit.mentioned"] }, "interactivity": { "url": "https://kit.acme.dev/ketvia/interactivity" }, "commands": [ { "command": "/github", "url": "https://kit.acme.dev/ketvia/commands", "description": { "en": "List and show tracked issues and pull requests" }, "usageHint": { "en": "[list | show owner/repo#number | help]" } } ], "distribution": "private"}The Kit
Section titled “The Kit”import { KetviaClient } from '@ketvia/kit';import { createGithubLiteKit } from '@ketvia/sample-github-lite';
const ketvia = new KetviaClient({ token: process.env.KETVIA_BOT_TOKEN ?? '' });const kit = createGithubLiteKit({ signingSecret: process.env.KETVIA_SIGNING_SECRET ?? '', conversationId: process.env.KETVIA_CHANNEL_ID ?? '', post: (message) => ketvia.messages.post(message), github: { assign: assignOnGithub, setState: setGithubState }, // your authenticated REST calls});
// kit.server.handle(request) serves /ketvia/events, /ketvia/interactivity and /ketvia/commands;// feed verified GitHub webhooks to kit.handleGithubWebhook('issues', payload).pnpm --filter @ketvia/sample-github-lite start runs it behind Node’s http module (see src/main.ts for the
environment variables, including the GitHub X-Hub-Signature-256 check). While developing, expose it with a tunnel
and ketvia kits dev (CLI). pnpm --filter @ketvia/sample-github-lite test signs requests
with signRequest and calls server.handle directly.