This guide is for getting a real Telegram bot paired quickly so you can verify the extension surfaces in the Pi coding agent.
gateway-messagingis a Telegram-first runtime baseline (queue/action/diagnostics)gateway-ingressis a Hono ingress contract package for webhook + polling normalization- slash command surface:
/gateway status
If you need full production bot behavior, treat this as the pairing + ingress baseline and extend from here.
From repo root:
bun run setupVerify:
pi listExpected extension paths:
.../extensions/flow-system.../extensions/theme-switcher.../extensions/gateway-messaging.../extensions/notify-cron
Then open a fresh Pi coding agent session and run:
/gateway status
In BotFather:
- create token (example env name:
TELEGRAM_BOT_TOKEN) - choose a webhook secret token (example env name:
TELEGRAM_WEBHOOK_SECRET)
Use polling while developing locally (no public HTTPS endpoint needed).
gateway-ingress normalization helper for polling batches:
normalizeTelegramPollingBatch(bot, updates, dedupe)
You can feed updates from your polling process, then forward normalized events to your runtime.
Use Hono ingress endpoint:
POST /telegram/webhook/:bot
Required header:
X-Telegram-Bot-Api-Secret-Token: <secret>
The ingress contract returns:
{ ok: true, duplicate: false, idempotencyKey }for first-seen updates{ ok: true, duplicate: true }for duplicate updates401 { ok: false, reason: "invalid_secret" }when secret mismatch
import { createGatewayIngressApp } from "@codewithkenzo/gateway-ingress";
const app = createGatewayIngressApp({
telegram: {
webhookSecrets: {
primary: process.env.TELEGRAM_WEBHOOK_SECRET ?? "",
},
},
onTelegramEvent: async (event) => {
console.log("telegram event", event.idempotencyKey, event.chatId, event.text);
},
});
export default app;Once paired and installed:
/gateway status
/flow profiles
/theme list
If /theme or /flow is missing, run:
pi install ./extensions/theme-switcher
pi install ./extensions/flow-systemThen restart the Pi coding agent.
pi listdoes not include extension path -> install it explicitly withpi install ...- commands still missing after install -> restart the Pi coding agent session
- command exists but no Telegram events -> verify token/secret and mode (polling vs webhook)
- webhook 401 -> wrong
X-Telegram-Bot-Api-Secret-Token - duplicate events unexpectedly -> check idempotency key source (
tg:<bot>:<update_id>)