Telegram for executives
Connect a Telegram bot so executives can query the assistant, pull reports and approve transactions from a phone. Document uploads happen in the web app.
What this enables
Telegram is a phone-side console for four jobs only. It does not take document or photo uploads.
| Job | What you do |
|---|---|
| Notifications | Approval and alert pushes arrive as Telegram messages. |
| Approvals | Approve or reject an AI task you are authorized for, with a YES/NO confirmation that expires after 15 minutes. |
| Questions | Ask in plain English — counts, balances, status — and get a chat answer. |
| Reports | Ask for a report and receive it as an Excel, PDF, CSV or TSV file, or ask for "text" to get a plain chat answer instead. |
Rule
Uploads are web-only
PDF, image and Excel ingestion happens in the web app — Procurement → Bill intake or the relevant module. The bot replies with a pointer and ingests nothing.
There are two parts. Part A is a one-time technical setup done by whoever has server access. Part B is done by the CEO in the web app.
Part A — one-time technical setup (administrator)
Watch
Administrator only
This part needs access to environment variables and the deployed URL. If you are a CEO or CFO, skip to Part B — your administrator completes Part A.
- A1
Create the Telegram bot
Open Telegram, start a chat with @BotFather and send /newbot. Give the bot a display name and a username ending in bot. BotFather replies with a bot token — treat it like a password.
- A2
Add the environment variables
Set TELEGRAM_BOT_TOKEN to the token. Set TELEGRAM_WEBHOOK_SECRET to a long random string — this signs every webhook request and, if it is missing, the webhook refuses all requests (fail-closed). Also set NEXT_PUBLIC_SITE_URL to the app's absolute public URL, which the setup call uses to derive the webhook target.
- A3
Deploy the app
The webhook route lives at /api/telegram/webhook. Deploy to production and confirm NEXT_PUBLIC_SITE_URL matches the public URL; for local testing expose a tunnel to your machine.
- A4
Register the webhook
Send an authenticated PUT to the webhook route with the header Authorization: Bearer <secret>. The secret is TELEGRAM_WEBHOOK_SETUP_SECRET when set, otherwise TELEGRAM_WEBHOOK_SECRET. The server derives the target from NEXT_PUBLIC_SITE_URL, registers it with Telegram and installs the command menu. The expected response is {"ok": true, "url": "…", "commands": true}. The webhook URL cannot be set with a GET query parameter.
- A5
Verify it is live
Open the route with only the secret parameter: GET /api/telegram/webhook?secret=YOUR_WEBHOOK_SECRET. The response shows the webhook info and command registration. The info should show your webhook url and pending_update_count 0. If last_error_message appears, the URL is not reachable — fix that first.
Note
Once is enough
You will not need to repeat Part A unless the bot token or the webhook URL changes.
Part B — the CEO maps the chats
- B1
Ask each executive for their chat ID
Send them these steps: open Telegram, search for your bot, press Start or send /start, and the bot replies with a numeric chat ID to send back to you. If no reply arrives, @userinfobot replies with the numeric ID.
- B2
Open Telegram Setup
Sign in as CEO and open Settings → Telegram Setup. The page is restricted to the CEO and platform SuperAdmins; other roles are redirected away.
Administration → Telegram/dashboard/admin/settings/telegram - B3
Map each chat ID
For each executive, select their name in Member, paste the chat ID in Telegram chat ID and click Map chat. The page confirms 'Chat ID mapped. The member can now use the bot.', and the mapping appears under Active mappings with status Linked.
- B4
Verify access
Ask each executive to send a message and confirm the bot responds — for example a cash-position question, /org, or an approval request. Do not expect file uploads here; documents are uploaded in the web app.
- B5
Remove a mapping when needed
In Active mappings, click the trash icon next to a member. The bot immediately stops accepting messages from that chat.
Rule
Chat IDs are the allowlist
A chat ID can be mapped to only one member, cannot be mapped to someone outside your workspace, and unmapped chats are ignored by the bot and reach no data. Approvals that need no entity selection run the exact same transaction as web approvals; invoice, sales-order, purchase-order and payment-receipt approvals stay on web so a human chooses the payer or payee. Telegram approvals post one journal entry and one audit entry.
Verifying each executive's access
| Test | Expected reply |
|---|---|
| Send 'what is our cash position?' | A cash summary covering bank, petty cash, receivables and payables |
| Send 'how many invoices are pending today' | A plain-English count of pending invoices |
| Send 'bill payments pending' | A plain-English count of pending bill payments |
| Send /org | Organization ID and your role |
| Ask for a report as Excel or PDF, e.g. 'P&L for last month, Excel' | The report arrives as an Excel or PDF file |
| Ask for 'text', 'summary' or 'no file' | A plain chat answer (not a .txt file); if no text answer exists, a file is sent |
| Ask to approve an eligible task | The match and a YES/NO prompt; a second confirmation message commits it |
| Ask to approve an invoice, sales order, purchase order or payment receipt | Guidance to the web approval card; reject remains available |
| Sales Manager asks to approve any AI task | A message that AI approvals are handled in the web app |
| Send /cancel | Cancels the live YES/NO confirmation |
Executive command reference
| Command | What it does |
|---|---|
| /start | Shows help; before mapping, replies with your chat ID |
| /help | Shows help |
| /approvals | Lists tasks awaiting your approval |
| /reports | Explains how to request a report (file or text) |
| /org | Shows your organisation and role |
| /settings | Points to Settings → Telegram in the web app |
| /cancel | Cancels the current YES/NO confirmation |
| Plain text | Ask anything in plain English — counts, cash, inventory, sales, trips — or request a report |
| Document or photo | Not accepted in Telegram — upload in the web app (Procurement → Bill intake or the relevant module) |
Troubleshooting
| Symptom | Cause and fix |
|---|---|
| Bot does not reply to /start during setup | Webhook not registered or URL unreachable — redo steps A4 and A5 |
| Webhook shows last_error_message | The URL must be HTTPS and publicly reachable — check the deployment or tunnel |
| TELEGRAM_BOT_TOKEN is not configured | The environment variable is missing in the environment the app runs in |
| This chat ID is already mapped to a member | The ID is bound to someone else — ask for the exact number the bot replied with |
| Executive gets no reply after mapping | Confirm the mapping exists, the member is active, and the chat is private rather than a group |
| Duplicate messages when asking a question | Expected safety net — the system deduplicates on Telegram's message ID |
| Executive sends a PDF or image in Telegram | The bot replies with a web-app pointer and ingests nothing — upload it in the web app (Procurement → Bill intake or the relevant module) |
| Executive expects to approve an invoice, PO, sales order or payment receipt | Those are entity-gated and approve only in the web card at /dashboard/approvals — Telegram offers reject only |
| Sales Manager sees no approvals | Expected — SALES_MANAGER has no AI approval authority; their invoice, order and bill approvals happen in the web modules |