Quick Start: Agent with Schedule
Give your agent the ability to create schedules:
User: “Me chama amanha as 9h pra eu enviar o relatorio”
Agent: uses create_schedule tool — Schedule “Lembrete relatorio” created. I’ll remind you tomorrow at 09:00.
What createScheduleTools() Returns
This function returns an object with 4 independent tools. You choose which ones to give your agent — don’t spread all tools blindly.
Choosing the Right Tools
createScheduleTools() returns:
| Tool Key | What It Does |
|---|---|
create_schedule | Creates a new schedule |
list_schedules | Lists all schedules for the agent |
update_schedule | Updates an existing schedule |
cancel_schedule | Cancels (deletes) a schedule |
Recommended Patterns
| Scenario | Tools to Include |
|---|---|
| Multi-user agent (customers, support) | create_schedule only |
| Single-user personal assistant | create_schedule + cancel_schedule |
| Internal team bot (shared context) | create_schedule + list_schedules + cancel_schedule |
| Admin/monitoring agent | All 4 (...createScheduleTools()) |
Tool Details
create_schedule
Creates a new scheduled execution. The LLM fills in the parameters based on the user’s request.
Input schema:
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Descriptive name (e.g., “Daily report reminder”) |
type | 'interval' | 'daily' | 'cron' | Yes | Schedule type |
interval | number | For interval type | Minutes between each execution (1-43200) |
time | string | For daily type | Time in HH:MM format, 24-hour (e.g., “09:00”) |
cron | string | For cron type | Cron expression (e.g., “0 9 * * 1-5”) |
timezone | string | No | IANA timezone (default: “UTC”) |
message | string | Yes | The message sent to the agent on each execution |
maxExecutions | number | No | Max times to fire (omit = unlimited) |
"Schedule created successfully. ID: {id}, Name: {name}, Type: {type}, Status: {status}"
list_schedules
Lists all active schedules for the current agent. Takes no parameters.
Returns: A formatted list of all schedules with ID, name, type, status, and message — or "No schedules found."
update_schedule
Updates an existing schedule. Only the fields you provide are changed.
Input: id (required) + any field from create_schedule (optional).
Returns: "Schedule updated successfully. ID: {id}, Name: {name}, Status: {status}"
cancel_schedule
Permanently deletes a schedule.
Input: id (required).
Returns: "Schedule {id} has been cancelled and deleted successfully."
The LLM decides which tool to call based on the conversation. You don’t need to write any routing logic — the tool descriptions guide the model. For example, when a user says “change my reminder to 10am”, the LLM will call
list_schedules first to find the ID, then update_schedule with the new time.How It Works End-to-End
Understanding the full lifecycle is important. Here’s what happens from creation to execution:Step-by-step breakdown
Creation (steps 1-4): When the agent callscreate_schedule, the SDK sends the configuration to the Runflow API. The API creates a SCHEDULER trigger in the database with the cron expression, next run time, and the message payload.
Scheduling (step 5): The Runflow trigger engine runs a periodic job (every minute) that queries the database for triggers where nextRun <= now. This is powered by the trigger-engine service.
Execution (steps 6-7): When a trigger is due, the trigger engine sends an HTTP POST to the agent’s endpoint with a payload containing the schedule data. The agent processes the message field as if it were a new conversation input.
Response (step 8): The agent’s response is delivered through the configured channel (API response, webhook, WhatsApp, etc.) depending on how the agent is deployed.
What the Agent Receives When a Schedule Fires
When a scheduled trigger fires, your agent receives anAgentInput with the schedule’s message as the input, plus metadata about the trigger:
- The
messagefield is what drives the agent’s behavior. Write it as if you were sending a chat message to the agent. The agent processes it with all its tools, RAG, and memory — just like a regular conversation. - The
metadatalets you know this was a scheduled execution (not a user message), which is useful for logging or conditional logic in tools.
Example: Agent Reacting to a Scheduled Message
Conversation Context (Automatic)
When an agent creates a schedule during a conversation whereidentify() is active, the SDK automatically captures the conversation context (entityType, entityValue, sessionId) and stores it in the trigger. When the schedule fires, this context is injected back into the agent input — so memory loads and the agent resumes the conversation.
main.ts
create_schedule tool captures and the trigger engine restores — the agent doesn’t know the difference between a live message and a scheduled callback.
Programmatic API
Use theschedule object directly in your code — useful for creating schedules in workflows, during deployment, or from external triggers:
Create a Schedule
List, Update, Cancel
Schedule Types
Interval
Runs every N minutes, starting from the moment it’s created:Daily
Runs at a specific time every day in the given timezone:Cron
Full cron expression support for advanced scheduling:| Expression | Description |
|---|---|
0 9 * * * | Every day at 9am |
0 9 * * MON-FRI | Weekdays at 9am |
0 9 * * MON | Every Monday at 9am |
0 */2 * * * | Every 2 hours |
0 9,18 * * * | At 9am and 6pm |
*/30 * * * * | Every 30 minutes |
0 0 1 * * | First day of every month at midnight |
The message Field: Designing Good Schedules
The message is the most important field — it’s literally what the agent “hears” when the schedule fires. Write it as a clear instruction:
Using in Workflows
Combine schedules with workflows to create automated follow-up sequences:Configuration Reference
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | Yes | — | Schedule name (shown in list and traces) |
type | 'interval' | 'daily' | 'cron' | Yes | — | Schedule type |
interval | number | For interval | — | Minutes between executions (1-43200) |
time | string | For daily | — | Time in HH:MM format (24-hour) |
cron | string | For cron | — | Standard 5-field cron expression |
timezone | string | No | UTC | IANA timezone (e.g., America/Sao_Paulo) |
message | string | Yes | — | Message delivered to the agent on each execution |
maxExecutions | number | No | 0 (unlimited) | Max number of executions. Use 1 for one-time reminders. Schedule auto-deactivates after reaching the limit. |
metadata | object | No | — | Custom key-value data stored with the schedule |
Schedule Isolation and Security
Schedules are scoped to the agent, not to the user. This has important implications:- An agent can only see schedules belonging to itself (not other agents). This is enforced at the API level using the agent ID from the SDK authentication context.
- All users of the same agent share the same schedule pool. If user A creates a daily reminder and user B calls
list_schedules, user B will see user A’s reminder. update_scheduleandcancel_schedulecan modify any schedule on that agent — including schedules created by other users.
Best Practices
-
For multi-user agents (customer-facing bots, support agents): only include
create_schedule. Don’t exposelist_schedules,update_schedule, orcancel_schedule— a user could see or delete another user’s schedules. - For single-user or internal agents: you can safely include all tools since there’s no cross-user risk.
-
For admin agents: use all tools with
observability: 'full'to track who creates, modifies, or cancels schedules.
Next Steps
Web Search
Give agents internet search capabilities
Connectors
Connect to external APIs
Observability
Track schedule executions and metrics
Tools
Create custom tools for scheduled tasks