Dynamically Generating Notion Filter Criteria

I need to dynamically create the filter to query a Notion database like this -

{
    "and": [{
        "property": "Client Manager",
        "rollup": {
            "does_not_contain": "2329aae8-e363-47b0-9e59-1f4cecaa5fcb"
        }
    }, {
        "property": "Tag",
        "date": {
            "equals": "2024-05-24"
        }
    }]
}

based on data that I’m sending to Make like this -

{
    "data": [{
            "Property": "Client Manager",
            "Type": "rollup",
            "Condition": "does_not_contain",
            "Value": "2329aae8-e363-47b0-9e59-1f4cecaa5fcb"
        },
        {
            "Property": "Last Contact",
            "Type": "date",
            "Condition": "equals",
            "Value": "2024-05-24"
        }
    ]
}

I’ll then use the filter as the body of my API request.

I’m using an array aggregator step for create my and[] array but when I try to generate the data structure for that step, by pasting in the above filter example, I get an output like this -

whereas I need to be able to set the property name, type and criteria dynamically. I’m not sure how to generate the data structure that I need?

Here’s a blueprint for the scenario -

blueprint (17).json (6.2 KB)

My solution in the end was to just construct the filter in a text aggregator, which also gives me some more flexibility in terms of the output -

2 Likes