Sync Contacts with Notes

What This Workflow Does

It syncs contacts from a Apple Contacts group named “Shortcuts demo” with Obsidian.

The end result will be a single note for each contact, with up-to-date contact details in the file properties. When the workflow is run again, it’ll find existing notes and update them. If it finds contacts without a note, it’ll create a new one.

The entries in Contacts will gain a clickable link to the Obsidian note.

Please note: The workflow will only work on macOS since it’s using Applescript which is not available on iOS.

Download

Download the Sync Contacts with Notes.shortcut workflow. Double-click the downloaded file to install the workflow in Shortcuts.

Requirements

  • Actions for Obsidian
  • Apple Contacts (Address Book)
  • Obsidian

Workflow Screenshot

Workflow history / Change log

2024-02-27

Checks whether contact has phone or email before attempting to add them to the dictionary.

2023-12-11

  • Uses Obsidian 1.4+ file properties instead of writing YAML
  • Uses Contacts’ own Shortcuts action for storing the Obsidian note URLs for contact
  • Obsidian note URLs in Contacts are stored under the label “URL” now (was: “Obsidian note”). It’s a result of using Contacts’ own actions.

2023-03-17

Adds support for contacts that have more than one phone number or mail address. Numbers and addresses are added to the front matter as YAML lists ([1, 2, 3]) now.

2023-02-09

Updated the downloadable workflow with a correctly Apple-signed version. Same workflow, just installable now. Sorry for the hiccup!

2023-02-03

  • First version.

Hey Carlo, super Sache!!! Genau was ich gesucht habe!
Wie kann ich den Workflow erweitern, damit auch Geburtstag, Adresse etc. mit übertragen werden?

Hey Carlo, great stuff!!! Exactly what I was looking for! How can I extend the workflow so that birthday, address, etc. are also transferred?

Welcome to the forum! I’ll answer in English, okay? :slight_smile: First, in the part that creates the body of the new note, add your new properties:

It’ll look like this:

---
contact_id: Contact ID
phone: [Combined Text]
email: [Combined Text]
birthday: [Birthday] 
---

The [Birthday] part is a property of the contact, so start with inserting the contact variable there, then tapping the contact variable, which will give you the list of all its properties, where you can pick the birthday.

In the part which updates the note, duplicate the “Search and replace” actions and update the properties as needed. The search term in the screenshot means “find the bit that says phone: and the rest of its line”, so sticking to the birthday example, you’d use /birthday: .*/ here.

Hope that helps!

Thank you!!! That helps a lot!!!

1 Like

It throws an error of the type: "Contacts got an error: Can’t get person {“Name”} of group “Contacts”. Does that mean this person is not in the group? It got a first person just fine but then stopped.

Which of the Applescripts is raising that error, i.e. which block?

The “run applescript with ” block. The Applescript itself is this one:

on run {fullName}
	tell application "Contacts"
		set human to person named fullName ¬
			in group named "Contacts"
		get id of human
	end tell
end run

Thanks!!

I’ve updated the workflow (see the version history in the original post). One less Applescript, one less problem.

I couldn’t reproduce the issue you have, @Reasder. The only thing I can think of what could cause this is a person w/o full name (maybe it’s just a company?), because the Applescript looks up the contact by its full name, and it checks not only the target group but all contacts.

Update: While updating the workflow I noticed that AFO’s Get Note Link action is returning incomplete URIs (the vault parameter is missing). I’m working on a fix right now!

I downloaded your Shortcuts from the app store today and set up the new pliugin in Obsidian. When I try to run this workflow, it quits every time after asking me for the name of my Obsidian vault.It stops before interacting with my contacts or Obsidian. Any ideas?

Welcome to the forum, @amerpie!

When you say “it quits”, what do you mean exactly? Do you get an error message, or does it just stop? Is it possible there are no contacts that fit the bill, i.e. that there is no Contacts group “Shortcuts demo”? (If you click the group name parameter in the “Find contacts” action, it should show you all groups in your address book. If you create a new group in Contacts, you’ll have to close the workflow and re-open it to make Shortcuts reload your address book structure.)

And you’ve completed the vault linking in the app, correct?

Thanks for getting back to me. The problem was that I didn’t create a contact list called Shortcuts Demo. Totally my fault.

1 Like

Hi,

what about contacts without phone or mail? If so, I receive an error :wink:

image

thanks for help (new to apple and shortcuts)
Matthias

Thanks, @mbrucke, good point. And welcome to the forum!

I’ve updated the workflow, it now checks whether contact has phone or email before attempting to add them to the dictionary. That should do the trick!

Hi,

thanks for the quick reply and many thanks for the tool, now I see light at the end of the tunnel ;). Trying to integrate O365 and obsidian for a while (which does not work well under Windows), but only recently switched to MacBook Air M2.

best
Matthias