Can I Filter Out Requests Based on the Request Body in HTTP Event Source?

This topic was automatically generated from Slack. You can find the original thread here.

Question about http event source: Can i filter out request based on the request body, so it won’t be created as an event

Yes, you can filter out requests based on the request body using a code step right after the HTTP / Webhook trigger in your workflow. Here’s an example of how you might do this: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { http: { type: "app", app: "http", }, }, async run({ steps, $ }) { const body = steps.trigger.event.body; if (body.includes("your_filter_condition")) { $.export("filtered", true); return; } // Continue with your workflow }, }); In this example, replace "your_filter_condition" with the condition you want to filter on. If the condition is met, the workflow will end early and not process the event further. Please note that this is a simple example and you might need to adjust the code to suit your specific needs. For example, if the body is a JSON object, you might need to parse it first with JSON.parse(body) and then check for specific properties.

Hi , I think you can use Pipedream Filter actions for this. So your workflow will only continue when a certain condition is met, this will help to resuce the limit consumed by the workflow

Though I think the best way to solve is to change how you send request to Pipedream, to only send relevant event

Thanks LEO.
The reason why i want to prevent the event for being created, is that i only need 10% of the incoming events.

And that it cost a credit for each event created

I was thinking of creating an if statement here…

Okay if you’d like to develop a custom http source for you usecase, you can refer to the guidlines here https://pipedream.com/docs/components/quickstart/nodejs/sources/#emit-items-in-an-rss-feed

Yes, that is just what I need.
Is it just me, or can’t i create a custom source via the UI?

Yeah for now it’s not possible to create source on UI. If you want to create custom source, you’ll need to do some coding in your local machine

Okay.
I Can see that we can do it this way also:

  1. Create a http source
  2. Edit the code of that http source

Thank for helping