Heartbeat Async Operator
A Telegram-based orchestration agent that turns user requests into background tasks, dispatches them to generic worker agents, wakes up on a heartbeat to inspect execution state, and proactively reports results back to Telegram.
If you have spent any time building with ChatBotKit, you have probably used tasks as a kind of to-do list. That works, but it barely scratches the surface. Tasks are really a background execution primitive, and once you start thinking about them that way, a much more powerful pattern emerges.
This blueprint is the result of that shift in perspective. Instead of a single bot that tries to do everything inline, we built an operator that lives in Telegram, accepts requests from the user, picks the right worker for the job, fires off a background task, and then gets out of the way. Every fifteen minutes a heartbeat wakes the operator back up so it can check on progress and push a Telegram update if anything changed. No polling from the user, no "let me check on that" - the operator comes to you.
The operator itself runs in five distinct modes. Intake mode is where a
conversational request turns into a structured background job with a clear
goal, schedule, and metadata. Dispatch mode is where the operator looks up
available worker bots from the blueprint and routes the task to the best
fit using the by-bot-id task templates. Heartbeat mode is the scheduled
wake-up cycle where the operator reviews recent execution state, spots
completions, failures, and stale jobs, then fires off a Telegram
notification. Status mode lets the user ask questions like "what is
running?" or "what failed today?" and get answers grounded in actual task
state rather than conversation memory. Recovery mode handles the messy
parts - retries, cancellations, re-routes - when a job goes sideways.
Behind the operator sit three generic workers. A Research Worker gathers information, drafts notes, and writes structured context files into a shared workspace. An Execution Worker runs commands, scripts, and file transformations. A Reporting Worker takes raw outputs and turns them into concise summaries and user-facing status reports. None of these workers encode a specific business domain. They model the reusable pattern of splitting background work into research, execution, and reporting phases, so you can drop them into almost any workflow.
The glue that holds it all together is task metadata. Every task the
operator creates carries fields like reportChatId (which Telegram chat
to update), workerName, workerBotId, goal, and
lastReportedStatus. That last field is the key to idempotent heartbeat
reporting. When the operator wakes up it compares each task's current
state against lastReportedStatus. If there is a change, the user gets a
Telegram message. If not, the operator stays quiet. No duplicate
notifications, no noise.
Where this gets interesting is customization. Need a fourth worker that handles database queries? Add it to the blueprint and the operator will discover it automatically via resource listing. Want faster updates? Change the heartbeat from fifteen minutes to five. Want to swap a generic shell-based worker for something domain-specific? Do it without touching the operator at all. The routing is based on bot IDs and task metadata, not hard-coded function calls, so the architecture scales with your needs rather than fighting them.
Backstory
Common information about the bot's experience, skills and personality. For more information, see the Backstory documentation.
Skillset
This example uses a dedicated Skillset. Skillsets are collections of abilities that can be used to create a bot with a specific set of functions and features it can perform.
List Worker Agents
Enumerate bot resources in the current blueprint so the operator can inspect available worker targets before dispatching background tasks.Create Background Task
Create a background task for a selected worker bot using its bot ID.List Background Tasks
List background tasks, optionally scoped to a specific worker bot.Fetch Task Details
Fetch detailed state for a specific background task.Update Background Task
Update schedule, metadata, or other task details for a worker-owned background task.Cancel Background Task
Cancel a background task that is no longer needed.Run Task Now
Force immediate execution of a background task regardless of its schedule.Read Workspace File
Read orchestration notes, worker outputs, and heartbeat reports from the shared workspace.Write Workspace File
Write orchestration notes, heartbeat reports, and handoff artifacts to the shared workspace.Notify Via Telegram
Send a proactive Telegram update to a chat tracked in task metadata.Read Research Files
Read files from the shared workspace to gather context and inspect existing notes.Write Research Files
Write structured notes and handoff artifacts for downstream workers.Basj
Run commands and scripts in the shared workspace.Read Execution Files
Read scripts, inputs, and prior outputs from the shared workspace.Write Execution Files
Write execution artifacts, logs, and generated outputs to the shared workspace.Read Reporting Files
Read raw outputs and task artifacts from the shared workspace.Write Reports
Write concise summaries and handoff documents to the shared workspace.
Terraform Code
This blueprint can be deployed using Terraform, enabling infrastructure-as-code management of your ChatBotKit resources. Use the code below to recreate this example in your own environment.
A dedicated team of experts is available to help you create your perfect chatbot. Reach out via or chat for more information.