Hey, I am working on something but kinda stuck. Here’s what I’m trying to do:I have 2 flows, a “fetching” flow and a “processing” flow.FETCHING FLOW
the fetching flow creates a REST API Get call and it can return anything between 1 and n results.
the next step is a node.js bit that gets all these results and processes them. sending them all 1 by 1 to a url. That URL is basically an endpoint of my next workflow.
PROCESSING FLOW
this next flow begins when it’s called by the previous one.
this just received the HTTP Request and is meant to get all the results to pass along.
I am then using a whatsapp template to send a text using a template
I configure everything just fine except I need to also enter my “Recipient Phone Number” which would come from my previous step but instead of taking each result as I was aiming for it’s just taking the last one so the rest although they are received, are unused.
So, my question is what am I missing to get it to work through the entire received list?
It sounds like you need to iterate through the results in your fetching flow and send each result to the processing flow. You can achieve this using a loop in your Node.js step. Here’s an example of how you can modify your fetching flow’s Node.js step to send each result to the processing flow:
import { axios } from "@pipedream/platform";
export default defineComponent({
async run({ steps, $ }) {
// Assuming you've fetched the results and stored them in an array called 'results'
const results = [/* your fetched results */];
// Replace this URL with the endpoint of your processing flow
const processingFlowURL = "https://your-processing-flow-endpoint.m.pipedream.net";
// Iterate through the results and send each one to the processing flow
for (const result of results) {
await axios($, {
method: "POST",
url: processingFlowURL,
data: result,
});
}
},
});
Make sure to replace the processingFlowURL with the actual endpoint of your processing flow. This code will send each result as an individual HTTP POST request to your processing flow, which should then process each result and send the WhatsApp message as expected.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.