Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/darkzOGx/youtube-automation-agent/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The YouTube Automation Agent runs on a comprehensive schedule that handles content generation, publishing, analytics, and optimization tasks automatically. This guide explains each scheduled task and how to customize them.
All times are based on your server’s local timezone. Ensure your system time is correctly configured.

Daily Schedule Overview

Here’s what happens automatically each day:
TimeTaskFrequencyDescription
6:00 AMContent GenerationDailyGenerate new video content
Every 15 minPublish QueueContinuousCheck and publish scheduled videos
9:00 AMAnalytics CollectionDailyGather performance data
10:00 PMOptimizationDailyUpdate SEO and keywords
8:00 AM SundayStrategy ReviewWeeklyAnalyze and adjust content strategy
3:00 AM SaturdayDatabase MaintenanceWeeklyBackup and cleanup

Scheduled Tasks Detail

1. Daily Content Generation (6:00 AM)

Cron Expression: 0 6 * * * This is the primary automation task that creates new video content.

What Happens

1

Check Content Buffer

System verifies if new content is needed based on:
  • Current scheduled videos (default: maintain 3-day buffer)
  • Posting frequency setting (daily, every-2-days, 3-per-week, weekly)
  • Last generation timestamp
2

Generate Content

If content is needed, runs full pipeline:
  1. Content Strategy Agent selects topic
  2. Script Writer Agent creates script
  3. Thumbnail Designer Agent generates thumbnail
  4. SEO Optimizer Agent optimizes metadata
  5. Production Management Agent compiles assets
  6. Publishing Scheduling Agent queues for upload
3

Log Results

Records generation event to database with:
  • Content ID
  • Topic and title
  • Scheduled publish time
  • Success/failure status

Smart Buffer Management

The system intelligently decides whether to generate content:
// Content buffer check logic
const upcomingContent = await getUpcomingSchedule(3);
const bufferDays = 3; // configurable

if (upcomingContent.length >= bufferDays) {
  console.log('Skipping - sufficient content in pipeline');
  return;
}
The default 3-day buffer ensures you always have content ready, even if the system experiences downtime.

2. Publish Queue Processing (Every 15 Minutes)

Cron Expression: */15 * * * * Continuously monitors and publishes scheduled content.

Processing Flow

  1. Query Database: Get all content with status = 'scheduled' and publishTime <= NOW()
  2. Upload to YouTube: Use YouTube Data API v3 to upload video
  3. Update Status: Mark as published with YouTube video ID
  4. Enable Monitoring: Add to analytics tracking queue
# Monitor publish queue activity
curl http://localhost:3456/schedule
Example Response:
[
  {
    "id": "content_001",
    "title": "The Art of Digital Storytelling",
    "publishTime": "2024-01-16T14:00:00.000Z",
    "status": "scheduled"
  },
  {
    "id": "content_002",
    "title": "Understanding Visual Narratives",
    "publishTime": "2024-01-17T14:00:00.000Z",
    "status": "scheduled"
  }
]

3. Daily Analytics Collection (9:00 AM)

Cron Expression: 0 9 * * * Collects performance data for recently published videos.

Collection Process

1

Identify Recent Videos

Fetch all videos published in the last 7 days:
SELECT * FROM publish_schedule 
WHERE status = 'published' 
AND published_at > datetime('now', '-7 days')
ORDER BY published_at DESC
2

Query YouTube Analytics

For each video, collect:
  • View count
  • Watch time
  • Average view duration
  • Likes, comments, shares
  • Click-through rate
  • Audience retention
  • Traffic sources
3

Calculate Performance Score

Generate composite performance score (0-100) based on:
  • Engagement rate (30%)
  • View velocity (25%)
  • Retention rate (25%)
  • CTR (20%)
4

Store Results

Save analytics to database with 2-second delay between API calls to avoid rate limits.
# View collected analytics
curl http://localhost:3456/analytics

4. Weekly Strategy Review (8:00 AM Sunday)

Cron Expression: 0 8 * * 0 Analyzes performance and adjusts content strategy.

Review Process

  1. Aggregate Weekly Data
    • Collect analytics for all videos from past 7 days
    • Identify top 3 performers
    • Calculate average performance score
  2. Extract Insights
    const insights = {
      topPerformingTopics: weeklyAnalytics.topPerformers
        .map(video => video.videoDetails.title)
        .slice(0, 3),
      averageScore: weeklyAnalytics.averagePerformanceScore,
      recommendation: score > 80 ? 'excellent' : 'needs_improvement'
    };
    
  3. Optimize Publishing Times
    • Analyze when your audience is most active
    • Adjust default publish time (currently 2:00 PM)
    • Update scheduling algorithm
  4. Update Content Focus
    • Feed top-performing topics to Content Strategy Agent
    • Adjust content style preferences
    • Update keyword priorities

5. Daily Optimization Tasks (10:00 PM)

Cron Expression: 0 22 * * * Maintains and improves existing content.

Optimization Tasks

1

Re-optimize Low Performers

Identifies videos with performance score < 50 in last 30 days:
  • Re-analyze SEO metadata
  • Generate updated titles/descriptions
  • Suggest thumbnail improvements
  • Update tags and keywords
2

Update Keyword Performance

Track keyword effectiveness:
  • Map keywords to video performance
  • Calculate keyword ROI
  • Build trending keyword database
  • Update SEO strategy
3

Cleanup Old Files

Remove temporary files:
  • Temp directory: Files older than 7 days
  • Uploads directory: Files older than 30 days
  • Maintains storage efficiency

6. Database Maintenance (3:00 AM Saturday)

Cron Expression: 0 3 * * 6 Weekly maintenance ensures system health.

Maintenance Operations

  1. Create Backup
    const backupPath = await db.backup();
    // Saves to: ./backups/backup_YYYY-MM-DD_HH-mm-ss.db
    
  2. Database Statistics
    {
      "totalContent": 45,
      "publishedVideos": 42,
      "scheduledVideos": 3,
      "analyticsRecords": 294,
      "databaseSize": "2.4 MB"
    }
    
  3. Cleanup Old Data
    • Remove analytics older than 90 days
    • Archive completed automation events
    • Optimize database indexes

Customizing the Schedule

Change Content Generation Time

Edit schedules/daily-automation.js:
// Change from 6:00 AM to 8:00 AM
this.scheduledTasks.set('daily-content-generation', 
  cron.schedule('0 8 * * *', async () => {
    if (this.isEnabled) {
      await this.runDailyContentGeneration();
    }
  })
);

Adjust Posting Frequency

Modify the content buffer settings in your database:
// Set posting frequency
await db.setSetting('posting_frequency', 'every-2-days');

// Options:
// - 'daily': Generate content every day
// - 'every-2-days': Generate every 2 days
// - '3-per-week': Monday, Wednesday, Friday
// - 'weekly': Once per week

Change Content Buffer Size

// Maintain 5-day buffer instead of 3
await db.setSetting('content_buffer_days', '5');

Adjust Analytics Collection Frequency

// Collect analytics every 6 hours instead of daily
this.scheduledTasks.set('analytics-collection',
  cron.schedule('0 */6 * * *', async () => {
    await this.collectDailyAnalytics();
  })
);

Monitoring Automation

View Automation Status

Check current automation state:
curl http://localhost:3456/health
Response includes:
{
  "status": "healthy",
  "initialized": true,
  "agents": ["strategy", "scriptWriter", "..." ],
  "timestamp": "2024-01-15T10:30:00.000Z"
}

View Recent Automation Events

Query the automation events log:
SELECT * FROM automation_events 
ORDER BY created_at DESC 
LIMIT 10;
Event Types:
  • daily_content_generation
  • queue_processing
  • analytics_collection
  • weekly_strategy_review
  • daily_optimization
  • database_maintenance

Dashboard Monitoring

The web dashboard at http://localhost:3456 displays:
  • Next scheduled generation time
  • Automation status (active/paused)
  • Recent automation activity log
  • System health score

Controlling Automation

While the schedule is automated, you maintain full control:

Pause Automation

// Temporarily pause all automation
await automation.pauseAutomation();
Pausing automation stops scheduled content generation but allows manual operations to continue.

Resume Automation

await automation.resumeAutomation();

Stop All Tasks

// Completely stop all scheduled tasks
await automation.stopAutomation();

System Health Monitoring

The automation system includes self-monitoring:

Hourly Health Checks

Every hour, the system performs:
1

Database Connectivity

Verifies database is accessible and responsive.
2

Scheduled Task Status

Confirms all cron jobs are running properly.
3

System Resources

Monitors memory usage and uptime.
4

Health Score Calculation

Generates score 0-100:
  • 100: Perfect health
  • 80-99: Good health
  • 50-79: Warning state
  • Below 50: Critical issues
// Health check results
{
  "timestamp": "2024-01-15T14:00:00.000Z",
  "database": true,
  "scheduledTasks": {
    "daily-content-generation": true,
    "publish-queue-processing": true,
    "daily-analytics": true,
    "weekly-strategy-review": true,
    "daily-optimization": true,
    "database-maintenance": true
  },
  "systemResources": {
    "uptime": 86400,
    "memory": {
      "heapUsed": 45.2,
      "heapTotal": 68.8
    }
  },
  "healthScore": 100
}

Failure Notifications

When tasks fail, the system:
  1. Logs error details to database
  2. Logs to console with ERROR level
  3. Stores failure in automation_events table
  4. Continues other scheduled tasks
// Example failure log
{
  "event_type": "daily_content_generation",
  "status": "error",
  "data": {
    "error": "OpenAI API rate limit exceeded"
  },
  "created_at": "2024-01-15T06:00:00.000Z"
}

Best Practices

Keep the automation running continuously for best results. The system learns and improves over time.
For New Channels:
  • Posting frequency: daily
  • Content buffer: 3 days
  • Manual topic selection for first 5-10 videos
For Established Channels:
  • Posting frequency: every-2-days or 3-per-week
  • Content buffer: 5 days
  • Full automation with strategy agent

Monitoring Checklist

  • Check dashboard daily for first week
  • Review analytics after each video publishes
  • Verify health endpoint returns “healthy”
  • Monitor content buffer stays above 2 days
  • Review weekly strategy insights
  • Check database backups are being created

Troubleshooting

Content Not Generating

Check automation status:
curl http://localhost:3456/health
Common causes:
  • Automation paused: Resume with resumeAutomation()
  • Buffer full: Content buffer already satisfied
  • API rate limits: Wait for quota reset
  • Missing credentials: Run npm run credentials:setup

Videos Not Publishing

Verify publish queue:
curl http://localhost:3456/schedule
Check for:
  • OAuth token expiration (reauthorize)
  • Network connectivity issues
  • YouTube API quota limits
  • Content stuck in “processing” status

Analytics Not Updating

Common issues:
  • Videos too new (wait 24 hours for data)
  • YouTube Analytics API not enabled
  • Insufficient video history
  • Rate limiting from excessive requests

Next Steps

Manual Operations

Override automation with manual control endpoints

Dashboard Guide

Master the web interface for monitoring

Agent Configuration

Customize individual agent behaviors

API Reference

Explore all available API endpoints

Build docs developers (and LLMs) love