An AI closer that answers my Telegram DMs like I would, and knows when to stay quiet.

Overview.
Traders who ask before they pay
Spirex sells AI trading analysis to Arabic-speaking traders. Before paying they ask about plans, payment by card or USDT, free reads and whether it is a scam, usually in a few short messages, a voice note or a screenshot of a receipt.
One founder, every time zone
Leads that wait hours go cold. A classic bot answers “ok” and stickers, invents prices, sends the wrong wallet, and promises win rates the brand refuses to promise.
An assistant with judgement
It answers like the founder, in Saudi dialect or the client's language, stays silent when silence is right, hands money and anger to a human, and nudges leads who went quiet, within hard limits written in code.
How it decides.
- 1It waits until the client stops typingMessages are buffered per chat. Typing and voice-recording events count as activity, so a burst of five messages gets one answer, not five. The wait is configurable and capped, so nobody waits long.
- 2It reads the whole conversationThe last 40 messages with the new ones flagged, a short memory note it keeps about this client, and any photo (a receipt, a chart) or voice note in the new messages, sent to the model as audio and images.
- 3One Gemini call decidesGemini on Vertex AI returns strict JSON against a schema: reply, skip or handoff, the sales stage, the client's language, at most two chat bubbles, a private reason for me and an updated memory note.
- 4Code checks the answer before it leavesAny USDT address that is not the real wallet, or any number-based win-rate claim, turns the reply into a handoff. Bubbles are stripped of the symbols a person never types on a phone.
- 5It types like a person, then sendsThe chat is marked read, the typing indicator runs for a time proportional to the text, and at most two bubbles go out. In draft mode the reply comes to me first.
The control room.
No dashboard to open: the closer reports where I already am. Drafts, handoffs and errors arrive as messages; commands go back the same way.
/ok 3 · /no 3 · /edit 3
Send, drop or rewrite a draft before it reaches the client.
/mode draft · /mode auto
Approve every reply, or let it answer directly.
/pause · /resume · /status
Stop it, restart it, or see replies in the last hour and waiting drafts.
/mute @user · /resume id
Keep it out of a chat, or bring it back after a handoff.
Real decisions.
Client sent only a sticker with no text or question. The playbook says to skip lone stickers.
Client sent a voice note asking how “watch and alert me” works. Explain it simply, in Saudi dialect.
Client lost money with the old version and asks if the new one is guaranteed not to lose. Be honest: no tool removes losses; the agent sets the stop before entry and says wait when the setup is unclear. Invite a free test.
Client wanted binary options. Spirex is built for spot and CFD trades with entry, stop and targets, so say so honestly, don't force the sale and leave the door open.
Existing customer: the app asks him to finish Partner activation instead of showing an active plan. The founder has to check the subscription.
An affiliate asks for a free month to promote Spirex on live streams. Partnership and free-plan decisions belong to the owner.
Guardrails.
Wallet lock
Every Tron address in a draft is compared with the one real wallet. A different address blocks the reply and alerts me.
No win-rate promises
A regular expression catches numeric win-rate, accuracy and “risk-free” claims in Arabic and English. Honest denials such as “there is no guaranteed profit” still pass.
Never first
It only answers people who wrote in. Follow-ups go only to chats where the client already wrote and our last message went unanswered.
Who it ignores
Bots, verified and official accounts, saved phone contacts (friends and family), muted users, and any chat I am handling by hand.
Rate limits
Replies are capped per chat and per hour. When a cap is hit, the chat is not marked as handled, so the next catch-up answers it.
Handoff silence
After a handoff it stays out of that chat for a set time, or until I send /resume with the chat id.
Architecture.
Engineering deep dives.
1. One answer per burst, not per message
- Problem
- People on Telegram send a question in four pieces. A bot that answers each piece sounds like a bot and repeats itself.
- Approach
- Each chat has a pending buffer and one waiting task. New messages and typing events push the deadline back; the task fires after a quiet period or a hard cap, then hands every buffered message id to one decision. The model is told to cover everything in a single reply.
- Trade-off
- A reply arrives a few seconds later than an instant bot would send it, which is also how a person behaves.
2. “Skip” is a valid answer
- Problem
- Most auto-responders answer everything: “ok”, a thumbs up, a spam link, a personal chat.
- Approach
- Skip and handoff are values of the same enum as reply in the response schema, with a sales stage beside them. The playbook lists when to stay silent; the log shows it does, from lone stickers to off-topic panic about an exchange being hacked.
- Trade-off
- A wrong skip leaves a client unanswered, so skips can be posted to Saved Messages while I build trust in it.
3. Rules in code, not only in the prompt
- Problem
- A prompt can be ignored. In a payments chat, one invented wallet address or one “90% win rate” is a real loss or a broken promise.
- Approach
- guard() runs after every model answer: the wallet check, the win-rate pattern, and a humanizer that removes dashes, slashes, quotes and list markers while keeping links intact. A blocked draft never reaches the client; I get the draft and the reason.
- Trade-off
- The win-rate pattern is deliberately narrow, so honest sentences that mention profit are not blocked.
4. Trust is earned in draft mode
- Problem
- Handing your sales inbox to a model on day one is reckless.
- Approach
- It starts in draft mode: every proposed reply arrives in my Saved Messages with the reason and stage, and I answer /ok 3, /no 3 or /edit 3 with my own text. /mode auto switches it on. If I write in a chat myself, my message is told apart from its own sends and it stands down.
- Trade-off
- Draft mode is slower; it exists for the first days, not forever.
5. Never miss a message
- Problem
- The closer runs on a MacBook. Lids close, Wi-Fi drops and Telegram does not always push every update.
- Approach
- Every two minutes a catch-up pass looks for private chats whose last message is the client's, from the last three hours, newer than what was already handled, and queues them. launchd starts it at login and restarts it if it crashes, wrapped in caffeinate so the Mac stays awake while it runs.
- Trade-off
- If the Mac is fully off, clients wait until it is back on.
6. Follow-ups with manners
- Problem
- Leads go quiet after the price. A human would nudge once or twice; a spammer would nudge forever.
- Approach
- Every ten minutes it looks for chats where our message was the last one, 3 hours and then 24 hours ago. The model decides whether a nudge is right and writes one short message that ends with a question. Only in Saudi daytime, at most 20 an hour, never to stages like not_interested, spam or paid.
- Trade-off
- Two nudges at most; a lead who wants more attention than that gets it from me.
7. Knowledge anyone can edit
- Problem
- Prices and rules change weekly. Changing them should not mean changing code.
- Approach
- The model reads four Markdown files on every call: the product, prices and payment steps; an objection map (value, trust, effort, time, identity, risk) adapted from the open-source objection-destroyer method; the tone and closing playbook; and the auto-trading FAQ. Facts not in the files do not exist: the model hands off instead of guessing.
- Trade-off
- About 30 KB of context per call, which a Flash model handles cheaply.
8. A model call that fails safely
- Problem
- APIs rate-limit, models get renamed and credits run out, always at the worst time.
- Approach
- Calls go to the Vertex AI endpoint with a chain of fallback models. 429 and 5xx errors retry with backoff, 400 to 404 move to the next model, 402 (no credits) stops at once, and a JSON answer cut short is retried. If everything fails, nothing is sent to the client and I get a message.
- Trade-off
- Python standard library only for HTTP, so there is nothing to break on upgrade.
What's next.
What I would fix first
It runs on a laptop, so a powered-off Mac means slower answers; it belongs on a small always-on server. The Telegram session file is full access to the account and needs the protection of a secret, not a file. Replies are counted, but not yet linked to payments, so I can't yet say how many sales it closed.
Roadmap
Cross-check closed chats against paid accounts (the read-only Spirex Reach scanner already sorts the inbox that way), build an evaluation set from past conversations so prompt changes are tested before they go live, and reuse the same brain for WhatsApp and Instagram DMs.