# The Pocket Foreman: make your AI text your phone when it needs you (and keep working after you tap)
Your AI agent only works while you're sitting there babysitting it. The second you step away, it stalls — stuck on one yes-or-no it can't answer alone, and your whole night is gone. This is the exact setup I use to fix that: when an agent hits a decision, it texts my phone with two buttons, and it keeps working the moment I tap. By the end you'll have a tiny approval bot running on any machine with Node — including a $5 server.
The kit is free. On Instagram you can also comment PHONE and the bot will DM it to you; everywhere else the download button above is it.
What the system actually is
It's a tiny Telegram bot, a token, and a poll loop — that's the whole trick. No database, no account, no dashboard, no hosting:
- `ask.js` — the foreman. It sends a yes/no question to your phone with Approve and Skip buttons, then blocks until you tap and exits
0(approve),1(skip), or3(timed out). No token lives in the file — it reads two environment variables. - The 10-minute setup — BotFather gives you a bot token; one
getUpdatescall gives you your chat id. That's the entire configuration. - The approve-loop pattern — how to wire
ask.jsinto a real agent: gate a risky step, keep the rest of the run moving while one question is pending, and offer more than two choices.
The trick that makes it compound: ask.js doesn't care what the question is — it's just a string. You wire up BotFather once, and from then on every agent and every project you build asks the *same* phone line instead of stalling forever.
The full step-by-step
1. Make the bot (3 min). In Telegram, message @BotFather, send /newbot, and copy the token it gives you. That's your TELEGRAM_BOT_TOKEN — treat it like a password, never commit it.
2. Get your chat id (3 min). Message your new bot once (it can only reply after you message it first), then run curl -s "https://api.telegram.org/bot$TOKEN/getUpdates" and read "chat":{"id":...}. That number is your TELEGRAM_CHAT_ID.
3. Set the two env vars (1 min). export TELEGRAM_BOT_TOKEN=... and export TELEGRAM_CHAT_ID=.... ask.js reads them from the environment; it never stores a token itself.
4. Test it (2 min). node ask.js "Pocket Foreman is live — approve?" — your phone buzzes with the question and two buttons. Tap Approve → the script exits 0. That exit code is how any script reads your decision.
5. Wire it into a real step. In any shell or agent: if node ask.js "Deploy to prod?"; then ./deploy.sh; else echo "held"; fi. The run continues either way — it never sits there waiting.
Gate the risky things, keep working on the rest
The point isn't to ask about everything — it's to reach you for exactly the calls that need your judgment, and to keep the agent productive meanwhile.
| Good places to gate (ask your phone) | Leave it running (no need to ask) |
|---|---|
Deploy, git push, publish | Running tests |
| Delete / destructive ops | Writing docs |
| Spending money | Building the next safe task |
| A fork the agent can't judge | Formatting, linting |
| End-of-run sign-off | Reading / summarizing |
For a long autonomous run, don't let one pending question freeze everything. Fire ask.js in the background, keep the other safe tasks moving, and only block on the one answer you actually need — the pattern file shows the exact snippet.
The part everyone misses
Most people bolt an approval prompt onto one script and stop there. The leverage is that the foreman is topic-agnostic and shared: the same ask.js reaches the same phone from every agent you ever run. You don't rebuild it per project — it becomes a habit the whole factory shares. Wire it once; from then on nothing you build stalls forever waiting on a decision only you can make.
Tools & links
- [Claude Code](https://docs.claude.com/en/docs/claude-code) — the agent that hits the decisions
ask.jsgates. The only real requirement (plus Node 18+ for the built-infetch). - Telegram + @BotFather — free, already on your phone; provides the bot token and the buttons.
- The kit itself —
ask.js, the 10-minute setup, the approve-loop pattern, and a README, all in one zip: download it here.
One honest number
In a representative good week, 23 approvals came straight to my phone while I was away from my desk — meetings, errands, dinner — instead of an agent sitting frozen until I got back. That's a representative figure to show the shape of it, not an audited stat; the real win is simply that "away from my keyboard" stopped meaning "everything stops."
One step to take today
Do steps 1–4 above — make the bot, grab your chat id, and run one test ask.js. Even before you wire it into anything, you'll have proven the loop: a question on your phone, a tap, a decision your scripts can read. From there, gate your next risky step and let the agent keep working while you answer from wherever you are.