Loading...
Loading...
Automates macOS Contacts via JXA with AppleScript dictionary discovery. Use when asked to "automate contacts", "JXA contacts automation", "macOS address book scripting", "AppleScript contacts", or "Contacts app automation". Covers querying, CRUD, multi-value fields, groups, images, and ObjC bridge fallbacks.
npx skill4agent add spillwavesolutions/automating-mac-apps-plugin automating-contactsautomating-mac-appsautomating-mac-appsname()emails().push()add ... to.people.push.whosemakeContacts.save()person.id().id()const Contacts = Application("Contacts");
const email = "ada@example.com";
try {
const existing = Contacts.people.whose({ emails: { value: { _equals: email } } })();
const person = existing.length ? existing[0] : Contacts.Person().make();
person.firstName = "Ada";
person.lastName = "Lovelace";
// Handle multi-value email
const work = Contacts.Email({ label: "Work", value: email });
person.emails.push(work);
Contacts.save();
// Handle groups with error checking
let grp;
try {
grp = Contacts.groups.byName("VIP");
grp.name(); // Verify exists
} catch (e) {
grp = Contacts.Group().make();
grp.name = "VIP";
}
Contacts.add(person, { to: grp });
Contacts.save();
console.log("Contact upserted successfully");
} catch (error) {
console.error("Contacts operation failed:", error);
}automating-contacts/references/contacts-basics.mdautomating-contacts/references/contacts-recipes.mdautomating-contacts/references/contacts-advanced.mdautomating-contacts/references/contacts-dictionary.mdautomating-contacts/references/contacts-pyxa-api-reference.md