this is my workflow where i am sending multiple queries at webhook in the form
{
“queries”: [
“Does your company have a program or policy to manage greenhouse gases? Have you set publicly available greenhouse gas reduction targets? If yes, what are those targets?”,
“Does your company have a program or policy to manage energy consumption? Have you set publicly available energy reduction targets? If yes, what are those targets?”,
“Does your company have a program or policy to manage water? Have you set publicly available water reduction/quality targets? If yes, what are those targets?”,
“Does your company have a program or policy to manage solid waste? Have you set publicly available solid waste reduction targets? If yes, what are those targets?”,
“Do you have an end of life process in place for your products? Specifically TELUS wants to ensure that no product purchased by TELUS will end up being “reclaimed” in a non-OECD country.”,
“Please list any hazardous materials utilized or produced during the manufacturing of this equipment. If hazardous materials are used, please describe how and where (country) any hazardous waste products are disposed of.”
]
}
and what to search if the answer to this query is present in the qna document, i yes then append the result in the json which i will be returning back, if not found move forward to llm models which will use a document uploaded by me to aswer that query.
now the task is i want to send the query one by one so i am using this merge node to merge my query with the qna sheet(answers to some standard queries] and my merge node is looking like this
where first row is the query and rest of the rows are query to search in.
i tried multiple ways to write the code to get my response as found:true/false, if true then answer also extracted from the qna and return it to the final answer json in making. PLEASE HELP stuck on it since very long.
Hi, not sure but just try to this code
queries = _input.all()[0].json[“queries”]
qna_data = _input.all()[1:] # skip the first item
results =
for query in queries:
found = False
answer = “”
for item in qna_data:
if item.json["Query"].strip().lower() == query.strip().lower():
found = True
answer = item.json.get("Response", "")
break
results.append({
"query": query,
"found": found,
"answer": answer if found else None
})
return [{“json”: result} for result in results]
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.


