Hey everyone,
I’m currently building a workflow where I want to check if a patient coming from a Webhook already exists in my Supabase Patients
table.
Here’s what I’m trying to achieve:
- A patient submits a form → Webhook is triggered.
- Then getting all the Patients from Subabase to check (based on Full name, email, Date of Birth).
- Aggregate node to make all Patients in 1 list.
- The IF Node should check the result of the Supabase query:
- If the patient exists → Continue the workflow normally .
- If not → create the patient first, then continue the workflow.
The problem:
- Sometimes the IF Node returns true (patient exists), even though the patient is definitely not in the database.
- Other times, when I change how I reference the data (e.g., from
{{$json["phone_number"]}}
as a string vs. accessing the result array), it returns false, even if the patient does exist. - The result seems to depend on how I structure the IF condition (e.g., comparing string vs. checking array length or object presence).
My idea for a solution:
If the IF Node logic in n8n continues to be unreliable, I’m thinking of solving this by:
- Creating a custom Supabase Edge Function (e.g.,
check_patient_exists
) that:
- Takes the info as input
- Returns a simple
true
orfalse
depending on whether the patient exists or not
- Then in n8n:
- I use an HTTP Request node to call this function
- Based on the returned data, I route the logic in a clean and reliable IF Node:
true
→ continuefalse
→ create patient, then continue
My question to the community:
- What do you think?
- Is there a clean way to solve this directly in n8n without having to build a custom Supabase function?
- Or is a custom API endpoint or Edge Function the most reliable way to handle this check?
- Or is there any way to fix it with another ways?
Would really appreciate your input or experience with similar setups!
Thanks in advance