I have a flow that my users can use once for free. When a user registers the first time, their IP address is stored in a Google sheet. I am trying to make it so that once they are registered if they come back to try and get the freebie again it ends the workflow after the IF node and sends them an email and a coupon. I have tried the IF node with no luck but I think the real problem is I don’t know how to search the IP that comes in (from the webhook) when my user signs up against the stored IP addresses of previous users in the Google Sheet. I have been so close I think but then the data that is passed is all wrong. I have learned so much about this awesome software over the last couple of months but I don’t know a lot of code and I’ve been stuck on this problem for days. Thank you for any help.
What is the error message (if any)?
No error just not getting the results I am expecting I think my process is wrong.
Please share the workflow
Share the output returned by the last node
Information on your n8n setup
n8n version: - 0.220.0
Database you’re using (default: SQLite): MYSQL
Running n8n with the execution process [own(default), main]:
Running n8n via [Docker, npm, n8n.cloud, desktop app]: Ubuntu 22.04
Hi @wtheory, the exact process obviously depends on how your data is structured, but you probably want to use the Merge node instead of the IF node in such a scenario. It allows matching values from two different sources against each other, allowing you to compare webhook data with Google Sheet data.
Here’s an example. Let’s assume your sheet looks like this:
Now with this information we can set up a Merge node to compare the query.ip field from our webhook with the IP field from our sheet. It can either pass on a dataset if it finds a match or pass on a dataset if there is no match.
So if you want to work with two branches (IP exists/IP does not exist) you would need to add two Merge nodes, one for each case. This is how it could look like in a workflow:
I’ve replaced the actual sheets and webhook nodes with Code nodes just providing mock data, so the workflow can run out of the box.
Now, when testing this with an IP from our sheet (like 184.108.40.206), the webhook data will be sent to the top branch:
When testing an IP not on the sheet (like 220.127.116.11) the bottom branch handling new IPs will run:
Hope this helps! Let me know if you have any questions on the example