The Problem
I wanted an AI assistant I could talk to on Telegram at any time of day — one that would check for my messages, think about them, and reply thoughtfully. Perplexity Computer has all the capabilities to make this work: it can call APIs, manage files, and run scheduled tasks. But there's a catch — its minimum scheduling frequency is one hour.
Waiting up to 60 minutes for a reply during an active conversation? That's not a conversation. That's email. I needed something smarter.
The Solution: Adaptive Acceleration
The system I built starts with a simple hourly polling schedule, then dynamically accelerates when it detects I'm actively chatting. The key insight is a technique I call the minute-shift trick: instead of changing the polling frequency (which isn't possible), you change which minute of the hour the task fires on.
A scheduled task set to fire at :00 every hour can be shifted to :05, then :10, then :15 — creating a chain of checks that are only 5 minutes apart, all while technically maintaining an hourly schedule.
How It Works
The Tier System
The system uses a 5-tier acceleration model tracked in a simple state file:
| Tier | State | Behavior | Next Check |
|---|---|---|---|
| 0 | Idle | Checks every hour on :00 | 60 min |
| 1 | Active | New message found — accelerate | 5 min |
| 2 | Cooling | No new message — still checking | 5 min |
| 3 | Cooling | Still nothing — keep checking | 5 min |
| 4 | Cooling | Final cooldown check | 15 min |
| Reset | Idle | No activity — back to baseline | 60 min |
If I send a new message at any tier during cooldown, the system immediately jumps back to Tier 1 and resumes 5-minute checks. It's like a conversation partner who stays alert while you're talking and gradually relaxes when you go quiet.
The Minute-Shift Trick
Here's a walkthrough of the system in action. Say the baseline fires at :00 each hour, and I send a message at 2:03 PM:
| Time | What Happens | Cron After |
|---|---|---|
| 2:00 PM | Scheduled check finds my 2:03 PM message. Replies. Sets tier 1. | :05 |
| 2:05 PM | Check fires. I replied again. Tier stays at 1. | :10 |
| 2:10 PM | No new message. Tier 1 → 2. | :15 |
| 2:15 PM | No new message. Tier 2 → 3. | :20 |
| 2:20 PM | No new message. Tier 3 → 4. | :35 |
| 2:35 PM | No new message. Tier 4 → reset to 0. | :00 |
| 3:00 PM | Back to normal hourly baseline. | :00 |
The cron expression is always hourly. The only value that changes is the minute number. Each escalation calculates the current UTC time, adds 5 (or 15) minutes, and updates the cron to fire at that new minute mark.
The Escalation Handoff
There's one important architectural detail: background scheduled tasks in Perplexity Computer can't modify their own schedule. So the background task escalates to the main conversation with a message like:
"TELEGRAM SCHEDULE UPDATE: New message detected and replied. acceleration_tier=1. Please update cron to run 5 minutes from now."
The main conversation receives this, calculates the correct UTC minute, and updates the scheduled task. This adds a small delay (usually under a minute) but effectively achieves 5-minute polling during active conversations.
The Architecture
The complete message lifecycle flows through 9 steps:
- You send a message — your Telegram app delivers it to your bot
- Scheduled task fires — Computer's cron triggers at the scheduled minute
- Read state file — the task reads
telegram_state.jsonfor tracking data - Fetch new updates — calls
getUpdateswith the last processed offset - Reply on Telegram — composes and sends replies through the bot
- Update state file — writes new tracking data and sets acceleration tier
- Escalate for schedule change — sends escalation with new timing request
- Main conversation updates cron — calculates UTC minute and updates the schedule
- Next check at new minute mark — system loops back, now at :05 instead of :00
Key Gotchas
- Send /start first — you must message
/startto your bot before Computer can reach you. It's a Telegram requirement for all bots. - Usernames vs. numeric chat IDs — the
@usernameformat often doesn't work for sending messages. Computer discovers your numeric chat ID automatically. - Duplicate prevention — the state file tracks
last_processed_update_idas the single source of truth. No duplicates, ever. - Edited messages — Telegram sends these as separate
edited_messageupdates. The system ignores them to avoid re-processing. - Timing nuance — if the calculated minute has already passed for the current hour, the cron fires at that minute in the next hour. Computer handles this math automatically.
The Result
What started as a one-hour polling loop became a responsive AI assistant that adapts to my behavior in real time. During active conversations, I get replies within 5-7 minutes. When I go quiet, the system gracefully winds down to conserve tokens. It's the best of both worlds — always available, never wasteful.
The full guide with step-by-step setup instructions, exact prompts to give Computer, and all the technical details is available as a PDF below.
Download the Full Guide
Adaptive Telegram Polling with Perplexity Computer — 13-page PDF with step-by-step instructions, prompts, architecture diagrams, and troubleshooting tips.