Skip to main content

Method

await sdk.scheduledMessages.createScheduledMessage(options: CreateScheduledMessageOptions): Promise<ScheduledMessageData>
Schedules a message to be sent at a specific time. Supports both one-time and recurring schedules with flexible interval types.

Parameters

options
CreateScheduledMessageOptions
required
Configuration for the scheduled message

Returns

ScheduledMessageData
object
The created scheduled message

Examples

One-Time Scheduled Message

// Schedule a message for 3 seconds from now
const scheduledFor = Date.now() + 3 * 1000;

const scheduled = await sdk.scheduledMessages.createScheduledMessage({
  type: "send-message",
  payload: {
    chatGuid: "iMessage;-;+1234567890",
    message: "This is a scheduled message!",
    method: "apple-script",
  },
  scheduledFor,
  schedule: { type: "once" },
});

console.log(`Scheduled message ID: ${scheduled.id}`);
console.log(`Will send at: ${new Date(scheduledFor).toLocaleString()}`);

Recurring Daily Message

// Schedule a daily good morning message starting tomorrow at 9 AM
const tomorrow9am = new Date();
tomorrow9am.setDate(tomorrow9am.getDate() + 1);
tomorrow9am.setHours(9, 0, 0, 0);

const daily = await sdk.scheduledMessages.createScheduledMessage({
  type: "send-message",
  payload: {
    chatGuid: "iMessage;-;+1234567890",
    message: "Good morning!",
    method: "apple-script",
  },
  scheduledFor: tomorrow9am.getTime(),
  schedule: {
    type: "recurring",
    intervalType: "daily",
    interval: 1,
  },
});

console.log(`Scheduled recurring message ID: ${daily.id}`);
console.log(`First occurrence: ${tomorrow9am.toLocaleString()}`);
console.log(`Repeats: every day`);

Weekly Reminder

// Schedule a weekly reminder every Monday at 8 AM
const nextMonday = new Date();
const daysUntilMonday = (1 - nextMonday.getDay() + 7) % 7 || 7;
nextMonday.setDate(nextMonday.getDate() + daysUntilMonday);
nextMonday.setHours(8, 0, 0, 0);

const weekly = await sdk.scheduledMessages.createScheduledMessage({
  type: "send-message",
  payload: {
    chatGuid: "iMessage;-;+1234567890",
    message: "Weekly team sync in 1 hour!",
    method: "apple-script",
  },
  scheduledFor: nextMonday.getTime(),
  schedule: {
    type: "recurring",
    intervalType: "weekly",
    interval: 1,
  },
});

Notes

  • All timestamps are in milliseconds (use Date.now() or new Date().getTime())
  • For recurring messages, scheduledFor sets the first occurrence time
  • The interval types determine the frequency: hourly, daily, weekly, monthly, or yearly
  • Use interval to skip periods (e.g., interval: 2 with intervalType: "weekly" sends every 2 weeks)
  • Scheduled messages persist until deleted or the schedule completes

Build docs developers (and LLMs) love