• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

Steps to Set Filter in Pabbly Hook

In Pabbly Hook, Filters allow you to permit events conditionally based on the contents of their Headers, Body, Query, or Path.
Purpose of Filters: Filters in Pabbly hooks allow you to control which webhook requests are processed based on specific criteria. They help ensure that only relevant requests trigger actions, making the process efficient and targeted. Filters can be applied to the body, headers, query parameters, and path segments of incoming requests. In simple words ,A filter is a condition or rule applied to incoming data to determine if it should be processed further or blocked the request based on condition.

Use Case for Rate Filters:
  • Allowing only events with useful information to pass through to a destination.
Filters syntax
Filters utilize JSON, and support matching on any value (string, number, boolean, null), on nested objects, and on arrays. There is also support for special operators. For a full rundown of supported schema.

1. Body Filter

A Body Filter is used to apply rules on the content within the request body. This type of filter is useful when you need to check if certain fields in the payload contain specific values.
  • Example: Body Filtering on the status field to process only messages with "status": "active".
View attachment 49227

1730195461202.png


  • If "status": "active" is not matched in body it will block the request.
  • Example: Filtering on the status field to process messages with "status": "Inactive".

1730195432145.png


2. Header Filter

A Header Filter checks specific headers in the request, allowing you to validate metadata or control data processing based on headers.

  • Example: Header Filtering on Content-Type to process only requests where "Content-Type": "application/json".
1730195875897.png


1730196232848.png


  • If "Content-Type": "application/json" is not matched it will block the request.
  • Example: Filtering on the Content-Type field to process messages with "Content-Type": "plain/text".
1730196896736.png


3. Query Filter

A Query Filter is used to filter requests based on query parameters. This is helpful when specific information, like IDs or action types, is passed as URL query parameters.

  • Example: Query Params Filtering on the user_id query parameter to process requests only for a specific user "user_id":"12345".
1730197126245.png


1730197924629.png

  • If "user_id":"12345" is not matched it will block the request.
  • Example: Filtering on the field to process messages with "user_id":"678910".
1730197875116.png


Complex matches using operators.​

Operators allow for more complex matching strategies, beyond simple equivalency tests.

OperatorSupported TypeDescription
$gtenumber, stringGreater than or equal to
$gtnumber, stringGreater than
$ltnumber, stringLess than
$ltenumber, stringLess than or equal to
$eqarray, number, object, stringEqual (or deep equal)
$neqarray, number, object, stringNot Equal (or deep not equal)
$inarray, stringContains
$ninarray, stringDoes not contain
$startsWithstringStarts with text
$endsWithstringEnds with text
$orarrayArray of conditions to match
$andarrayArray of conditions to match
$existbooleanUndefined or not undefined
$notValid syntaxNegation

1. Value Operators

These operators are used for comparisons between values such as numbers, dates, or even strings.

  • $eq: Matches if the value is equal to the specified value.
  • $neq: Matches if the value is not equal to the specified value.
  • $lt: Matches if the value is less than the specified value.
  • $lte: Matches if the value is less than or equal to the specified value.
  • $gt: Matches if the value is greater than the specified value.
  • $gte: Matches if the value is greater than or equal to the specified value.
  • $in: Matches if the value is in the array.

Example:​

Code:
{
"product": {
"price": {
             "$gte": 100,
              "$lte": 500
             },
"category":  {
"$in": ["electronics", "furniture"]
                    }
                }
}

  • Explanation: This filter will match if the price of the product is between 100 and 500, and the category is either "electronics" or "furniture".
Example passing payload:

Code:
{
  "product": {
    "price": 250,
    "category": "electronics"
  }
}

Blocking Payload​

For the payload to block, any of the following can be true:

  • price is less than 100 or greater than 500
  • category is not "electronics" or "furniture"
Example blocking payload:

Code:
{
  "product": {
    "price": 50,
    "category": "clothing"
  }
}

This way, any payload outside the specified range for price or category would result in the request being blocked by the filter.

2. String Operators

These operators are useful for pattern matching or working with string values.

  • $contains: Matches if the string contains the specified value.
  • $notContains: Matches if the string does not contain the specified value.
  • $startsWith: Matches if the string starts with the specified value.
  • $endsWith: Matches if the string ends with the specified value.
  • $regex: Matches if the string matches the given regular expression.

Example:​

Code:
{
  "product": {
    "title": {
      "$startsWith": "Smart",
      "$regex": {
        "pattern": "Pro$",
        "flags": "i"
      }
    }
  }
}
  • Explanation: This filter matches products where the title starts with "Smart" and ends with "Pro" (case-insensitive).
To satisfy the filter : The product.title in the payload should start with "Smart" and end with "Pro" (case-insensitive). Here are examples of payloads that would pass and block according to this filter.


Passing Payload​


Code:
{
"product": {
"title": "SmartPhone Pro"
}
}

  • Explanation: The title starts with "Smart" and ends with "Pro", meeting both the $startsWith and $regex conditions.

Blocking Payload​

  1. Title does not start with "Smart":
    Code:
    {
    "product": {
    "title": "Phone Pro"
    }
    }
  2. Title does not end with "Pro":
    Code:
    {"product": {
    "title": "SmartPhone Plus"
    }
    }
  3. Title starts with "Smart" but is case-sensitive mismatch for regex:
    Code:
    {"product": {
    "title": "smart Pro"
    }
    }
Each of these examples fails to meet the combined requirements of $startsWith and $regex.

3. Existence Operators

These operators deal with the presence or absence of certain fields.

  • $exists: Matches if the field exists or not.
  • $empty: Matches if the field is empty or not (works for strings, arrays, and objects).

Example:​

Code:
{
  "user": {
    "email": {
      "$exists": true
    },
    "address": {
      "$empty": false
    }
  }
}

Here's how to structure the payload to pass and block the request based on the provided filter:

Explanation of the Filter:​

  • user.email.$exists: true — The payload must have an email field under user.
  • user.address.$empty: false — The address field under user should not be empty (for strings, this means it shouldn't be an empty string ""; for arrays, it shouldn't be []; for objects, it shouldn't be {}).

Payload for Passing (matches filter):​

Code:
{
"user": {
"email": "[email protected]",
"address": "123 Main St, Springfield"
}
}

Payload for Blocking (does not match filter):​

  1. Missing email:
    Code:
    {
    "user": {
    "address": "123 Main St, Springfield"
    }
    }
  2. Empty address:
    Code:
    {
    "user": {
    "email": "[email protected]",
    "address": ""
    }
    }
Each of these blocking examples fails one part of the filter criteria, so they would result in the request being blocked.
  • Explanation: This filter will match users that have an email field and whose address field is not empty.

4. Logical Operators

Logical operators allow you to combine multiple conditions.

  • $and: Matches if all of the specified conditions are true.
  • $or: Matches if any of the specified conditions are true.
  • $not: Matches if the specified condition is false.

Example (nested with logical operators):​

Code:
{
  "$or": [
    {
      "product": {
        "price": {
          "$lt": 50
        }
      }
    },
    {
      "$and": [
        {
          "product": {
            "category": {
              "$eq": "clothing"
            }
          }
        },
        {
          "product": {
            "availability": {
              "$eq": "in_stock"
            }
          }
        }
      ]
    }
  ]
}
  • Explanation: This filter matches if the price of the product is less than 50, or if the category is "clothing" and the product is in_stock.
The filter will pass if:
  1. product.price is less than 50.
  2. OR product.category is "clothing" and product.availability is "in_stock".

1. Payload to Pass the Filter:​

The following payload meets the filter because product.price is less than 50.

Code:
{
"product": {
"price": 45,
"category": "electronics",
"availability": "out_of_stock"
}
}

Alternatively, this payload also passes because product.category is "clothing" and product.availability is "in_stock":

Code:
{
"product": {
"price": 100,
"category": "clothing",
"availability": "in_stock"
}
}

2. Payload to Block the Filter:​

The following payload does not meet any condition and thus would be blocked:

Code:
{
"product": {
"price": 75,
"category": "electronics",
"availability": "out_of_stock"
}
}

In this blocked payload, product.price is not less than 50, product.category is not "clothing", and product.availability is not "in_stock".
 

Attachments

  • 1730195231167.png
    1730195231167.png
    74.4 KB · Views: 4
  • 1730197165166.png
    1730197165166.png
    73.5 KB · Views: 4
  • 1730197804200.png
    1730197804200.png
    115.5 KB · Views: 5
Last edited:
Top