This topic was automatically generated from Slack. You can find the original thread here.
Hi, I am new to Pipedream, and I would like to ask how can I react on a subscribed webhook (rest api) only when the return of the elements increase (aka new element added)?
To react to a webhook when a new element is added, you can create a Pipedream workflow with an HTTP trigger. In the workflow, you can add a code step to process the incoming webhook data and check if the number of elements has increased. Here’s an example: 1. Create a new workflow and add an HTTP trigger. 2. Add a code step with the following code: export default defineComponent({ async run({ steps, $ }) { // Get the previous and current data from the webhook payload const prevData = steps.trigger.event.body.prevData; const currentData = steps.trigger.event.body.currentData; // Check if the number of elements has increased if (currentData.length > prevData.length) { console.log("New element added"); // Perform your desired action here } else { console.log("No new elements added"); } }, }); Replace prevData and currentData with the appropriate properties from the webhook payload. Now, whenever your webhook is triggered, this workflow will run and check if the number of elements has increased. If so, it will perform the desired action within the if block.