Sorting through contact groups from notion

What are you trying to achieve?

Hello everyone, this might be a very simple problem but I can’t for the life of me figure out how to solve it. I’m trying to create a simple connection between a contacts table in Notion to Google Contacts and sort them out by group.

Steps taken so far

So far, I’ve filter out those contacts with no groups, and that works just fine. Then filter those with group existing and it works, but if I add a fallback option in case it does not find the group name, it goes to that one by default on the first try, rather than iterate through the whole list first. How would I go about this?

Hello @cchulia, I think sharing your blueprint here would be helpful. Because we don’t know which variables are being used in the filters, and it’s possible you reused an earlier one which is causing the outcome you get.

Right, sorry, I didn’t know that was a possibility :sweat_smile:

This is the blueprint for the solution I was working on.

blueprint.json (183.9 KB)

Hello @cchulia; thanks for the blueprint.

In looking at the filter, I see 2.name looking to match 27.name. However, it’s possible these don’t align as you expect. Instead, given that 27.name exists, should be enough to proceed with that branch.

Next, in the hundreds of scenarios I’ve created, I, ah, have never found the need to use that fallback option because filtering suffices.

Therefore, by checking for 27.name exists, your fallback should be checking for 27.name does not exist.

The above changes should get the logic flow you desire.

My problem with that solution is rather than iterating through the whole list and then deciding its not there, the moment it checks the first item is not it, it defaults to the other branch.

Hiya @cchulia; regarding the following, I think it’s my confusion area.

Please walk me through a few examples of what you want to have happen. I hope your explanation will cause the brain bulb to turn on.

Such as what does “goes to that one by default on the first try” mean?

And why is “rather than iterate through the whole list first” important?

So, the main goal was to sort through a Notion database and import the items inside as contacts. Name and most “common” fields are fine, but getting Contacts to accept Tags as a group was a challenge.

My original blueprint tried to:

'2. Watches for new contacts and updates. —>
'21. Router: One route creates filters database items with no Tags, and crates “simple” contacts, with no group. The other route moves all items with tags along. ---->

Here’s where things get tricky, it might have a simple solution but I couldn’t figure it out at the moment. I tried different solutions and the one I ended up with was:

'19. Lists all groups already created ---->
'23. Router: Creates two routes. In one, the filter checks if a group name the same as the Notion tag exists. If it does, it creates a contact and adds it to the group. If not it goes the other route, creates a group with that name and then creates the contact.

The reason I needed the filter to iterate thorugh all the input was to check if the name in Tags corresponded to ANY group. The way it is now, it checks if it is equal to the first group (bundle 01) and if it just so happen to be, great, if not, rather than checking if it is equal to any other group, it just goes the other way and tries to create a group with that name, which might give an error if the group existed and was in another bundle later.

Anyway, my current solution uses a “Tools” module to map the groups into one variable and then the filters check if the resulting string contains the tag. Not the most elegant, and I’m trying to improve it, but it sort of works. :sweat_smile:

The explanation helps @cchulia;

One option is to pull the groups at the beginning to then do a contains check to then decide creating or not that group. The challenge is when the groups change because an earlier new contact has tag Z that gets created and a later contact wants that tag too.

It’s possible to work around these, yet frankly we’re not dealing with an efficient solution.

How often are you running this routine?

Ideally it would be running on a schedule, so I could add contacts in Notion and have it be updated for Gmail and my phone contacts. (And the other way, though that’s a whole different problem)

Hello @cchulia; I’m very sorry, I think my brain left town while attempting to help you.

I realize now that after getting the 27.Google Groups lookup, we’re not iterating through them. We’re only checking the first result.

So we could iterate through them, when a match is found link it as desired. When no match is found after iterating through all, then we go to a fallback route, but not the built-in one.

More of a prior router, next branch that gets variable group found, and when that’s false, then create the group and associate the contact.

Similarly, we could use that group found variable to stop processing further modules, though the iterator will continue until done.

And now, the concept demo and blueprint,
DEMO:ITERATE:Variable Set & Get.json (18.8 KB)

Good luck!

2 Likes

Thank you! That certainly helped.

PS: Not relevant to this topic, but I can’t play the video on the message, not sure why. (Edge and chrome show the play botton grayed out and firefox just shows format invalid.)

Thanks, @cchulia for letting me know about the video issue.

Hiya, @Michaela, any luck knowing why Loom videos sometimes work or not?

1 Like

Hello @ImMichaelCannon

This is a known issue of Discourse, the software the community is built on. There is a way of fixing individual videos, but we need to keep track of them manually. It seems that we missed this one and I’m sorry about that. All should hopefully be working now.

1 Like

Good day, @Michaela; what’s a working by default alternative to Loom that you suggest?