Phase 6: Mini App
A Telegram Mini App served by the core under /app/, embedded in the binary. - API under /app/api/ with initData validated (HMAC, age) on every call - Pages: Home, Queue, Buy (target, product, invoice), History, Groups, group detail (Overview, Settings, Wallet, Usage) and Me - Every action runs through the same service, billing and scheduler code as the chat, so limits, prices and admin checks are decided on the server - Texts come from the catalog over the API; layout mirrors for RTL - Front end in web/miniapp (Vite, React, TypeScript); the build is committed and guarded by a source hash test; the Docker image rebuilds it - MINIAPP_ENABLED with an https PUBLIC_URL; entry points from /app, group settings and the over-limit offer - Browser test (make miniapp-e2e) against a core in test mode - Fix: each download attempt gets its own scratch directory, so a retry cannot lose its file to the cleanup of the failed attempt Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
51371da0e0
commit
4f11f939a0
@@ -118,6 +118,7 @@ Put a TLS reverse proxy (Caddy, nginx, Traefik) in front and set
|
||||
`PUBLIC_URL=https://bot.example.com` when you want any of:
|
||||
|
||||
- instant payment settlement (LNbits webhook) and the "Open in wallet" button
|
||||
- the Mini App
|
||||
- remote workers across the internet
|
||||
- Telegram webhooks instead of long polling (`TELEGRAM_MODE=webhook`,
|
||||
`WEBHOOK_URL`, `WEBHOOK_SECRET`)
|
||||
@@ -129,12 +130,50 @@ Routes the proxy must pass through:
|
||||
| `/telegram/webhook` | Telegram (webhook mode only) |
|
||||
| `/lnbits/webhook/<secret>` | LNbits |
|
||||
| `/pay/<id>` | Users pressing "Open in wallet" |
|
||||
| `/app/...` | The Mini App and its API, opened by Telegram clients |
|
||||
| `/worker/v1/...` | Remote workers. Allow long requests (30 s) and large uploads. |
|
||||
| `/healthz` | Your monitoring |
|
||||
|
||||
Without `PUBLIC_URL` the bot still works: long polling for Telegram,
|
||||
polling for payments, workers on the same network.
|
||||
|
||||
## The Mini App
|
||||
|
||||
The Mini App is a small web page that Telegram opens inside the chat. The
|
||||
core serves it; there is nothing extra to host.
|
||||
|
||||
1. Give the core a public HTTPS address and set it (see the section above).
|
||||
Telegram refuses Mini Apps over plain http.
|
||||
|
||||
```sh
|
||||
PUBLIC_URL=https://bot.example.com
|
||||
MINIAPP_ENABLED=true
|
||||
```
|
||||
|
||||
2. Restart the core, then open `https://bot.example.com/app/` in a browser.
|
||||
You should see one sentence asking you to open the page from Telegram.
|
||||
That means the app is served and refuses strangers, as it should.
|
||||
|
||||
3. Tell Telegram where the app lives. In @BotFather: `/mybots`, pick the
|
||||
bot, **Bot Settings**, **Configure Mini App**, **Enable Mini App**, and
|
||||
enter `https://bot.example.com/app/`. This is the bot's "main Mini App".
|
||||
It adds a **Launch app** button to the bot's profile and makes the link
|
||||
`https://t.me/<your bot>?startapp` work, which the bot uses in groups.
|
||||
|
||||
4. Send `/app` to the bot and press the button.
|
||||
|
||||
With the app on, `/app` shows an "Open app" button, group admins get a
|
||||
link from `/settings` straight into their group's page, and a download
|
||||
that is over the limit offers the shop inside the app.
|
||||
|
||||
The app has no login of its own. Telegram signs who the user is, and the
|
||||
core checks that signature with the bot token on every call. A signature
|
||||
older than 24 hours is refused, so an app left open for a day asks to be
|
||||
opened again.
|
||||
|
||||
If step 3 is skipped, the button in private chats still works. Only the
|
||||
`?startapp` links from groups and the profile button need it.
|
||||
|
||||
## Health and logs
|
||||
|
||||
- `GET /healthz` on the core answers 200 while the database is reachable.
|
||||
|
||||
Reference in New Issue
Block a user