Overview
Mini App
Full HAPI interface inside Telegram
Notifications
Permission requests and session updates
Deep Links
Jump directly to specific sessions
Inline Actions
Approve/deny permissions with buttons
Setup
1. Create a Telegram Bot
Open BotFather
Message @BotFather on Telegram
2. Configure the Hub
Set these environment variables:3. Start the Hub
4. Bind Your Telegram Account
The namespace suffix (
:namespace) is optional. Omit it for the default namespace.Configuration Options
Required
| Variable | Description | Example |
|---|---|---|
TELEGRAM_BOT_TOKEN | Token from @BotFather | 123456:ABC-DEF... |
HAPI_PUBLIC_URL | Public HTTPS URL | https://hapi.example.com |
Optional
| Variable | Default | Description |
|---|---|---|
TELEGRAM_NOTIFICATION | true | Enable/disable notifications |
CLI_API_TOKEN | Auto-generated | Shared secret for authentication |
Mini App Features
The Telegram Mini App provides the full HAPI experience:Session List
View all active and past sessions
Chat Interface
Send messages and view responses
Permission Control
Approve or deny tool access
File Browser
Browse files and view git diffs
Terminal Access
Remote terminal via web interface
Session Creation
Spawn new sessions on any machine
Accessing the Mini App
Open the Mini App in several ways:- Bot Command: Send
/appto your bot - Start Command: Send
/startand tap “Open App” - Deep Link: Tap notification links
- Telegram Menu: Use the Mini App menu button
Notifications
HAPI sends notifications for important events:Permission Requests
When an AI agent needs your approval:Tap Approve or Deny directly in the notification, or View Session to see full context in the Mini App.
Session Ready
When a session completes a task:Notification Settings
To disable notifications:- Right-click bot → Mute
Deep Links
HAPI generates deep links that jump directly to specific sessions:- Permission request notifications
- Session ready notifications
- Manually generated session links
How Deep Links Work
- User taps notification link
- Telegram opens your bot
- Bot launches Mini App with session ID
- Mini App navigates to that session
Bot Commands
The HAPI bot supports these commands:| Command | Description |
|---|---|
/start | Welcome message with Mini App link |
/app | Open the Mini App directly |
Architecture
How Telegram integration works:Authentication Flow
- User opens Mini App in Telegram
- Mini App sends Telegram initData to hub
- Hub verifies initData with Telegram
- Hub checks if Telegram ID is bound to namespace
- Hub issues JWT token
- Mini App uses JWT for API requests
Use Cases
Mobile-First Workflow
Use Telegram as your primary mobile interface:- Start session on desktop:
hapi - Get notification on Telegram when permission needed
- Approve directly in notification
- Get notified when task completes
- Open Mini App to send next instruction
Notification-Only Mode
Use Telegram just for notifications:- Enable Telegram integration
- Use PWA for main interface
- Get critical alerts via Telegram
- Act on notifications when convenient
Multi-User Teams
Each team member can bind their Telegram:- Each user gets their own namespace
- Each user binds Telegram with
CLI_API_TOKEN:username - Notifications go to the right person
- No shared Telegram account needed
Advantages Over PWA
Better iOS Support
No Safari limitations, full push notifications
No Installation
Works immediately, no install step
Telegram Ecosystem
Integrates with existing Telegram workflow
Reliable Notifications
Uses Telegram’s robust notification system
Security Considerations
Bot Token
Keep your bot token secure:- Never commit to git
- Use environment variables
- Rotate if compromised
Binding
Telegram binding is secure:- Uses Telegram’s initData verification
- Cryptographically signed by Telegram
- Can’t be spoofed
Public URL
YourHAPI_PUBLIC_URL should:
- Use HTTPS (required by Telegram)
- Be accessible only to authorized users
- Use authentication (CLI_API_TOKEN)
Troubleshooting
Bot Not Responding
Bot Not Responding
- Verify
TELEGRAM_BOT_TOKENis correct - Check hub logs for errors
- Ensure hub is running
- Test token with Telegram’s API
Mini App Won't Open
Mini App Won't Open
- Verify
HAPI_PUBLIC_URLuses HTTPS (not HTTP) - Check CORS settings include Telegram domains
- Ensure hub is accessible from public internet
- Test URL in browser first
Notifications Not Arriving
Notifications Not Arriving
- Check
TELEGRAM_NOTIFICATION=true - Verify Telegram account is bound
- Ensure bot isn’t muted in Telegram
- Check hub logs for send errors
Can't Bind Account
Can't Bind Account
- Verify
CLI_API_TOKENis correct - Check namespace if using multi-user setup
- Ensure hub is running and accessible
- Try logging in via web first
Deep Links Not Working
Deep Links Not Working
- Verify
HAPI_PUBLIC_URLis set correctly - Check bot username matches URL
- Ensure session ID exists
- Try
/appcommand as fallback
Tunneling for Development
Telegram requires HTTPS. For local development:Cloudflare Tunnel (Recommended)
https:// URL as HAPI_PUBLIC_URL.
ngrok
HAPI_PUBLIC_URL.
Tailscale
Enable HTTPS on your Tailscale network and use your machine’s Tailscale URL.Related Features
PWA
Alternative mobile experience
Remote Control
Switch between local and remote
Permissions
Control agent access to tools