Skip to main content

Scheduling Posts

Learn how to schedule posts for optimal engagement times.

Basic Scheduling

Schedule for Specific Time

const post = await flow.posts.create({
channelId: 'channel_123',
content: 'Scheduled post',
scheduledFor: new Date('2024-12-25T10:00:00Z'),
});

Schedule Immediately

Omit scheduledFor to post immediately:

const post = await flow.posts.create({
channelId: 'channel_123',
content: 'Posts right away!',
// No scheduledFor = immediate
});

Time Zones

All times are in UTC. Convert local times to UTC:

// Schedule for 9 AM EST (UTC-5)
const estTime = new Date('2024-12-25T09:00:00-05:00');
const utcTime = new Date(estTime.toISOString());

const post = await flow.posts.create({
channelId: 'channel_123',
content: '9 AM EST',
scheduledFor: utcTime,
});

Common Scheduling Patterns

Schedule for Tomorrow

const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
tomorrow.setHours(9, 0, 0, 0); // 9 AM

const post = await flow.posts.create({
channelId: 'channel_123',
content: 'Tomorrow at 9 AM',
scheduledFor: tomorrow,
});

Schedule for Next Week

const nextWeek = new Date();
nextWeek.setDate(nextWeek.getDate() + 7);
nextWeek.setHours(10, 0, 0, 0); // 10 AM

const post = await flow.posts.create({
channelId: 'channel_123',
content: 'Next week',
scheduledFor: nextWeek,
});

Schedule Multiple Posts

const posts = [];
for (let i = 0; i < 7; i++) {
const date = new Date();
date.setDate(date.getDate() + i + 1);
date.setHours(9, 0, 0, 0);

posts.push({
channelId: 'channel_123',
content: `Day ${i + 1} post`,
scheduledFor: date,
});
}

await flow.posts.createBatch({ posts });

Optimal Posting Times

Use channel analytics to find optimal posting times:

const analytics = await flow.channels.getAnalytics('channel_123');
const optimalTimes = analytics.optimalTimes; // ['09:00', '14:00', '18:00']

// Schedule at optimal time
const today = new Date();
const [hours, minutes] = optimalTimes[0].split(':');
today.setHours(parseInt(hours), parseInt(minutes), 0, 0);

const post = await flow.posts.create({
channelId: 'channel_123',
content: 'Optimized timing!',
scheduledFor: today,
});

Capacity Management

Channels can have capacity limits to prevent over-posting:

// Check capacity before scheduling
const capacity = await flow.channels.getCapacity('channel_123');

if (capacity.recommendedFrequency) {
// Schedule within recommended frequency
const posts = scheduleWithinCapacity(
channelId,
capacity.recommendedFrequency
);
}

Capacity limits help prevent over-posting. Use channel analytics to find optimal posting frequencies and times.

Updating Scheduled Posts

Update the scheduled time for queued posts:

// Only works if post is still 'queued'
await flow.posts.update(postId, {
scheduledFor: new Date('2024-12-26T10:00:00Z'),
});

Best Practices

  1. Use UTC: Always work in UTC for consistency
  2. Check capacity: Respect channel capacity limits
  3. Optimal times: Use analytics to find best posting times
  4. Batch schedule: Use batch operations for multiple posts
  5. Monitor status: Check post status to ensure delivery

Next Steps