Hi everyone,
I'm building a Zap that triggers when a Stripe Checkout session is completed. Based on the product purchased (Basic, Pro, or Custom), the Zap should search ClickUp to see if the lead already exists (matching by name or email).
If the lead exists, it should add a tag like basic_paid
, pro_paid
, or custom_paid
. If not, it should create a new task in the corresponding ClickUp space or list based on the membership type.
Looking for help validating this flow or optimizing the logic.
At the moment I am using code by zapier to try fix this (I am not a coder). Thing is I have added a test sub-task , but my code keeps on returning not found. I know the subtasks is there so why is this happening?
Also if there’s a better alternative on how to make this workflow I am open ears. Here is the code I am currently using.
Code is in JavaScript.
Input Data = name and email both dynamic pulled from stripe step
Code:
const name = inputData.name?.toLowerCase() || '';
const email = inputData.email?.toLowerCase() || '';
const searchQuery = name + ' ' + email; // Combine both for broader matching
const response = await fetch("https://api.clickup.com/api/v2/task/search", {
method: "POST",
headers: {
"Authorization": "pk_XXXXXXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"Content-Type": "application/json"
},
body: JSON.stringify({
query: searchQuery,
subtasks: true,
include_closed: false
})
});
const data = await response.json();
const tasks = data.tasks || a];
const match = tasks.find(task => {
const taskName = task.name?.toLowerCase() || '';
return taskName.includes(name) || taskName.includes(email);
});
Please any help would be amazing.
This post has been edited by a moderator to remove sensitive information. Please remember that this is a public forum and avoid sharing credentials, tokens, or other private details that could compromise your account security.