quickstart
clone, run the edge Worker locally, then go live โ Telegram, embed, first lead.
quickstart
you'll need Bun โฅ 1.1.34, a Cloudflare account (free), and a Telegram account.
1. run it locally
wrangler dev binds Workers AI and the Durable Object automatically โ you can drive the
full loop locally before touching Telegram.
in a second terminal, serve the widget demo and open it:
the demo page's <script> already points data-api at http://localhost:8787. open the
bubble (bottom-right), say hi, and you get an AI reply. that's the loop, minus Telegram.
without Telegram configured the chat still answers โ the topic mirror just no-ops. this is the deliberate "graceful degradation" behavior; you never need Telegram to try the AI.
2. go live โ the krispy init wizard (fastest path)
after you've created the KV namespace and set TENANT_SYNC_SECRET (see
self-host the edge), run the guided setup:
it walks you through four steps, each persisted as you go via POST /api/tenant/config:
- connect Telegram โ BotFather โ paste the bot token (validated live via Telegram's
getMe) โ supergroup-with-Topics + add-the-bot-as-admin โ chat id. - train your bot โ point it at a knowledge-base file, accept a starter template, or skip.
- embed the widget โ prints the copy-paste
<script>snippet, tenant baked in. - next steps โ how to run (
krispy dev/wrangler deploy) and test the loop.
re-run it any time โ it never clobbers fields you've already set.
3. the manual path (wrangler secrets)
prefer to do it by hand? the full sequence lives in self-host the edge. in short:
then register the Telegram webhook against your deployed Worker (see the guide).
4. your first lead
open a page with the widget embedded and chat until the AI decides a human is needed (ask for pricing, ask for "a real person", or trigger a form). the widget shows a small contact-capture form or a lead form; on submit, the values fan out to your Telegram topic (and email, if you configured a Resend key). a topic appears on your phone โ reply from Telegram, and your message lands live in the visitor's browser while the bot goes silent.