Loading...
Loading...
Automates macOS Messages (iMessage/SMS) via JXA with reliable service→buddy resolution. Use when asked to "automate iMessage", "send Messages via script", "JXA Messages automation", or "read Messages history". Covers send-bug workarounds, UI scripting for attachments, chat.db forensics, and launchd polling bots.
npx skill4agent add spillwavesolutions/automating-mac-apps-plugin automating-messageschat.dbautomating-mac-appsserviceTypeiMessageSMShandlesendMessages.send()const Messages = Application('Messages');
Messages.includeStandardAdditions = true;
function safeSend(text, handle, svcType = 'iMessage') {
const svc = Messages.services.whose({ serviceType: svcType })[0];
if (!svc) throw new Error(`Service ${svcType} missing`);
const buddy = svc.buddies.whose({ handle })[0];
if (!buddy) throw new Error(`Buddy ${handle} missing on ${svcType}`);
Messages.send(text, { to: buddy });
}try/catchreferences/ui-scripting-attachments.mdsend()chat.messages()~/Library/Messages/chat.dbchat.dbchat.dbchat.messages()sqlite3 -jsonreferences/database-forensics.mdsqlite3 ~/Library/Messages/chat.db "SELECT
CASE WHEN m.is_from_me = 1 THEN 'Me' ELSE 'Them' END as sender,
m.text,
datetime(m.date/1000000000 + 978307200, 'unixepoch', 'localtime') as date
FROM message m
JOIN handle h ON m.handle_id = h.rowid
WHERE h.id LIKE '%PHONE_NUMBER%'
ORDER BY m.date DESC LIMIT 10;"launchdrowidreferences/monitoring-daemons.mdMessages.services.whose({ serviceType: 'iMessage' })[0]svc.buddies.whose({ handle })[0]chat.dbreferences/control-plane.mdreferences/ui-scripting-attachments.mdreferences/database-forensics.mdreferences/monitoring-daemons.md