Get All Scheduled Messages
await sdk.scheduledMessages.getScheduledMessages(): Promise<ScheduledMessageData[]>
Retrieves all scheduled messages.
Returns
Array of all scheduled messages
Unique identifier for the scheduled message
The chat GUID this message is scheduled for
The message text that will be sent
Timestamp when the message will be sent
Timestamp when the scheduled message was created
The action type (e.g., “send-message”)
The full payload configuration
Example
const messages = await sdk.scheduledMessages.getScheduledMessages();
console.log(`Found ${messages.length} scheduled message(s)`);
for (const msg of messages) {
console.log(`[${msg.id}] ${msg.payload?.message}`);
console.log(` Scheduled for: ${new Date(msg.scheduledFor).toLocaleString()}`);
}
Update Scheduled Message
await sdk.scheduledMessages.updateScheduledMessage(
id: string,
options: UpdateScheduledMessageOptions
): Promise<ScheduledMessageData>
Updates an existing scheduled message.
Parameters
The ID of the scheduled message to update
options
UpdateScheduledMessageOptions
required
New configuration for the scheduled message (same structure as create)
Type of scheduled action (e.g., "send-message")
The updated message payload
The chat GUID to send the message to
The updated message text to send
Send method (e.g., "apple-script")
Updated timestamp for when the message should be sent
Updated schedule configuration ({ type: "once" } or recurring)
Returns
The updated scheduled message
Example
// Update a scheduled message to send 10 minutes from now
const updated = await sdk.scheduledMessages.updateScheduledMessage("12345", {
type: "send-message",
payload: {
chatGuid: "iMessage;-;+1234567890",
message: "Updated message text!",
method: "apple-script",
},
scheduledFor: Date.now() + 10 * 60 * 1000,
schedule: { type: "once" },
});
console.log(`Updated message ID: ${updated.id}`);
Delete Scheduled Message
await sdk.scheduledMessages.deleteScheduledMessage(id: string): Promise<void>
Deletes a scheduled message, preventing it from being sent.
Parameters
The ID of the scheduled message to delete
Returns
Promise that resolves when the message is deleted.
Example
await sdk.scheduledMessages.deleteScheduledMessage("12345");
console.log("Scheduled message deleted");
Complete Example
import { iMessageSDK } from "@photon-ai/advanced-imessage-kit";
const sdk = new iMessageSDK({ serverUrl: "http://localhost:3000" });
sdk.on("ready", async () => {
// List all scheduled messages
const messages = await sdk.scheduledMessages.getScheduledMessages();
console.log(`Found ${messages.length} scheduled message(s)`);
for (const msg of messages) {
console.log(`[${msg.id}] ${msg.payload?.message}`);
}
// Update a specific scheduled message
if (messages.length > 0) {
const firstId = messages[0].id.toString();
const updated = await sdk.scheduledMessages.updateScheduledMessage(firstId, {
type: "send-message",
payload: {
chatGuid: messages[0].chatGuid,
message: "Updated message!",
method: "apple-script",
},
scheduledFor: Date.now() + 5 * 60 * 1000, // 5 minutes from now
schedule: { type: "once" },
});
console.log(`Updated message ${updated.id}`);
// Delete it
// await sdk.scheduledMessages.deleteScheduledMessage(firstId);
// console.log(`Deleted message ${firstId}`);
}
});
await sdk.connect();
Notes
- Use
getScheduledMessages() to find the ID of a message you want to update or delete
- Updating a scheduled message completely replaces its configuration
- Deleting a scheduled message is immediate and cannot be undone
- For recurring messages, deleting stops all future occurrences