Because there is no API for searching a lead by email field for that CRM. There I tend to do it in n8n by using Filter or If or Switch node, I am not sure if there an ideal action for this step
If a lead is found by matching an email β Update the existing Contact
If a lead is not found by matching an email β Create a New Contact
If I use a Filter node, there will be no action if no lead is found.
If I use an If node, it will only work if a lead is found; otherwise, it will output the remaining leads from the list as false items.
If there was a search lead action for the CRM, the HTTP request would return 200 or 500. This can be used as a conditional action to either create a new contact or update an existing one.
The workaround is to simulate 200 / 500 in n8n. If so, how?
I hope someone has had a similar situation and found a solution they donβt mind sharing.
Thanks.
@Blueli , I would implement the workflow differently utilizing Merge nodes instead as depicted below
One of the Merge nodes is looking for a match in email addresses and the other checks if no match found. Thus, the first Merge outputs the form submission data when the email address it is not in CRM and the second one outputs the form submission data when the email address exists in CRM.
Pay attention to how each Merge node is configured to achieve the described behaviour. I also assumed the form field holding the email address is called just email but you can change it to what you actually have.