📊 Module Progress
🎯 Learning Objectives
📚 Theory
Advanced Cron Features
Now that you know basic cron, let's explore advanced scheduling features.
1. Webhook Delivery
Instead of running in a chat session, send results to a URL.
{
"delivery": {
"mode": "webhook",
"to": "https://your-server.com/endpoint"
}
}
Use case: Send daily reports to your own API.
2. Failure Alerts
Get notified when a cron job fails.
{
"failureAlert": {
"channel": "telegram",
"to": "347207938",
"after": 3 // Alert after 3 failures
}
}
3. Session Binding
Control which session the job runs in:
"main"→ Your main chat (JiXe)"isolated"→ Temporary session (auto-deletes)"session:my-session"→ Specific named session
4. Context Messages
Include previous chat history for context.
"contextMessages": 5 // Include last 5 messages as context
Real-World Advanced Examples
Example 1: Daily Report with Webhook
{
"name": "Daily Sales Report",
"schedule": { "kind": "cron", "expr": "0 18 * * *" },
"payload": { "kind": "agentTurn", "message": "Summarize today's sales data" },
"delivery": {
"mode": "webhook",
"to": "https://my-server.com/sales-report"
},
"sessionTarget": "isolated"
}
Example 2: Failure Alert for Critical Task
{
"name": "Backup Database",
"schedule": { "kind": "every", "everyMs": 86400000 },
"payload": { "kind": "systemEvent", "text": "Backup database to cloud" },
"failureAlert": {
"channel": "telegram",
"to": "347207938",
"after": 1
}
}
Best Practices for Advanced Cron
- Test Before Scheduling — Run the task manually first to ensure it works.
- Use Isolated Sessions for Heavy Tasks — Don't clog your main chat with cron outputs.
- Set Failure Alerts for Critical Jobs — If a backup or security check fails, you want to know immediately.
- Clean Up Old Jobs — Periodically review and remove jobs you no longer need.
Key Takeaway
Advanced cron = webhooks + failure alerts + session control. Use these for production-grade automation!
🧪 Hands-On Exercise
Design an advanced cron job with webhook and failure alerts.
Step 1: Define the Task
Scenario: You want a daily backup of critical files, with alert if it fails.
Task: Backup C:\Important\ to cloud storage
Step 2: Write the Cron JSON
{
"name": "Daily Backup",
"schedule": {
"kind": "cron",
"expr": "0 2 * * *",
"tz": "Asia/Kuala_Lumpur"
},
"payload": {
"kind": "systemEvent",
"text": "Backup C:\\Important\\ to cloud storage"
},
"sessionTarget": "isolated",
"failureAlert": {
"channel": "telegram",
"to": "YOUR-CHAT-ID",
"after": 1
}
}
This job runs daily at 2AM, uses isolated session, and alerts on first failure.
Step 3: Add Webhook (Optional)
If you have a server that logs backups:
"delivery": {
"mode": "webhook",
"to": "https://your-server.com/backup-log"
}
Step 4: Test the Job
Before scheduling, test manually:
You: "Backup C:\Important\ to cloud storage."
JiXe: runs backup → "Backup complete! 15 files backed up."
Step 5: Monitor
After scheduling, check:
- Did it run? (Check logs)
- Did it succeed? (Check delivery/alerts)
- Any failures? (Check Telegram for alerts)