Overview
When a scheduled task runs, Gorkie uses a different tool set optimized for asynchronous delivery. The primary task tool issendScheduledMessage, which delivers the final output of a scheduled task execution.
How Task Execution Works
- Trigger: A scheduled task reaches its
nextRunAttime - Execution: Gorkie processes the task prompt (can use sandbox, web search, etc.)
- Delivery: The
sendScheduledMessagetool sends results to the configured destination - Update: Task state is updated with next run time and status
sendScheduledMessage instead of reply for final output.
sendScheduledMessage
Send the final output of a scheduled task to Slack. This should be the last tool call in a task execution.Parameters
Final user-facing message to send. This is the primary output of your scheduled task.
Context
The tool receives context automatically from the task execution environment:Returns
Example Usage
When a scheduled task executes, Gorkie might use tools like this:Destination Types
ThechannelId determines where the message is sent:
- DM: If
channelIdis a user ID (starts withU), message goes to that user’s DM - Channel: If
channelIdis a channel ID (starts withC), message goes to that channel - Thread: If
threadTsis provided, message posts into that specific thread
Error Handling
IfsendScheduledMessage fails:
- The error is logged with task ID and destination details
- The scheduled task’s
lastStatusis set toerror - The
lastErrorfield stores the error message - The task remains enabled and will retry at the next scheduled time
listScheduledTasks chat tool:
Task Tool Lifecycle
Here’s the complete lifecycle of a task tool execution:1. Task Trigger
2. Execution Phase
Gorkie executes the task prompt with access to:- Sandbox: For code execution and data processing
- Web search: For real-time information
- Other chat tools: Most tools except
reply,react,scheduleReminder
3. Delivery Phase
4. Status Update
After execution:Differences from Chat Tools
| Feature | Chat Tools | Task Tools |
|---|---|---|
| Trigger | User message | Cron schedule |
| Context | SlackMessageContext | Task execution context |
| Output | reply tool | sendScheduledMessage tool |
| Interactivity | Real-time with user | Autonomous |
| Threading | Can reply to specific messages | Posts to configured destination |
| Available tools | All chat tools | Chat tools + sendScheduledMessage |
Best Practices
1. Clear Output Messages
Make scheduled task output self-contained and actionable:2. Handle Errors Gracefully
Use try-catch patterns in your task prompt:3. Use Sandbox for Heavy Processing
Delegate complex work to the sandbox:4. Provide Status Context
Include timestamps and status indicators:Common Patterns
Daily Digest
Weekly Report
Hourly Monitor
Debugging Failed Tasks
If a scheduled task fails:-
Check task status:
-
Review the last error:
-
Common issues:
- channel_not_found: Bot not in the target channel
- Timeout: Task took too long (increase efficiency or split into multiple tasks)
- Rate limit: Too many API calls (add delays or reduce frequency)
-
Fix and re-enable:
Security Considerations
- Channel permissions: Gorkie must be a member of the target channel
- User permissions: Only task creators can cancel their own tasks
- Rate limiting: Tasks are subject to Slack API rate limits
- Execution timeout: Tasks that run too long will be aborted
Next Steps
Scheduled Tasks Feature
Learn how to create and manage scheduled tasks
Chat Tools
Explore tools available during task execution
Sandbox Tools
Use code execution in scheduled tasks
Cron Expressions
Build and validate cron expressions