SDK Background Tasks and Scheduling
Most AI agents are reactive - they sit idle until a user types something. ChatBotKit's task system lets you schedule agent work, run long operations in the background, and build workflows that act on their own. Define tasks programmatically, set a schedule, assign a bot, and the platform handles execution. No polling loops, no cron servers, no custom infrastructure.
Whether you are building a daily standup summarizer, a self-learning agent, or a batch processor that works through documents while your team sleeps, background tasks turn your agents from passive responders into active participants.
Key Features
- Schedule recurring agent tasks - Heartbeat-style execution on hourly, daily, weekly, or custom intervals.
- Run long-running operations asynchronously - Kick off work that takes minutes or hours without blocking conversations.
- Pause and resume tasks - Disable a task temporarily without losing its configuration.
- Monitor task progress - Track execution history, check results, and debug failures through the SDK.
- Build proactive agents - Agents that send messages, reports, or alerts on a schedule rather than waiting for input.
- Process batch operations - Work through large datasets, document collections, or queue backlogs automatically.
Getting Started
Install the SDK and create a scheduled task:
npm install @chatbotkit/sdk
import { ChatBotKit } from '@chatbotkit/sdk'
const client = new ChatBotKit({
secret: process.env.CHATBOTKIT_API_SECRET,
})
// Create a task that runs daily at 9am UTC
const task = await client.task.create({
name: 'Daily Team Briefing',
description: 'Summarize overnight activity and post to Slack',
botId: '<bot-id>',
schedule: '0 9 * * *',
maxIterations: 50,
})
console.log(`Task created: ${task.id}`)
// Trigger a task manually (outside its schedule)
await client.task.trigger(task.id)
// List all running tasks
const tasks = await client.task.list({ status: 'running' })
Background tasks pair well with skillsets, MCP integration, and datasets to build fully autonomous agent workflows.