Keyrxng

Case study: Telegram micro-kernel integration (Workers + GitHub Actions)

Ubiquity OS · 2024 · Case study: Bridged a kernel with Telegram using Workers for Bot API and GitHub Actions for MTProto—auditable flows, low-friction UX, and clear boundaries.

So what?
create/close/reopen via CI chat lifecycle
Role
Engineer
Year
2024
Stack
Cloudflare Workers, Hono, GitHub Actions, Supabase
Read narrative
create/close/reopen via CI chat lifecycle

Problem

Collaboration happened in DMs (not auditable or rewardable). We needed kernel↔Telegram integration that could create, close, and reopen workrooms tied to issues—reliably and with minimal friction.

Constraints

Approach

  1. Bot handler in Cloudflare Workers (Hono) for fast, reliable Bot API.
  2. MTProto features via self-dispatching GitHub Actions workflows.
  3. Supabase session storage to persist authentication state.

System diagram

flowchart LR
  User[User Input] --> Worker[Telegram Bot Worker]
  Worker --> Classify[Event Classification]
  Classify --> Plugin[GitHub Plugin Action]
  Plugin --> MTProto[MTProto API workroom creation]
  MTProto --> Storage[Supabase/GitHub Storage]
  Storage --> Response[Response to User]
  Response --> Dispatch[Workflow Self-Dispatch]
  Dispatch --> Repo[Repository Actions]

Outcome

Design choices

Proof

Code excerpt — Workroom creation via MTProto (worker → action boundary)

export async function createChat(context: Context) {
  const { payload, adapters: { storage } } = context;
  const chatName = `@${payload.repository.full_name}#${payload.issue.number}`;
  const chat = await mtproto.createSupergroup({ title: chatName, description: `Task: ${payload.issue.title}` });
  await storage.handleChat({ action: ChatAction.CREATE, chatId: chat.id, repositoryId: payload.repository.id, issueNumber: payload.issue.number });
  return chat;
}

Workflow excerpt — Self-dispatched action executing kernel step

on:
  repository_dispatch:
    types: [create-chat, close-chat, reopen-chat]
jobs:
  compute:
    runs-on: ubuntu-latest
    steps:
      - name: execute directive
        run: npx tsx ./src/workflow-entry.ts

References