Skip to main content

Filtering Messages Sent to SyncHive

Inbound Filters in SyncHive

Inbound Filters are user-defined rules within SyncHive that manage incoming Messages. These filters are accessible and configurable through the SyncHive user interface, specifically within the Integration Shape UI section.

The primary advantage of using Inbound Filters is that they empower users with greater control over the data their Integrations receive. This ensures that only relevant and necessary information is processed, enhancing efficiency and data management.

To enable the use of Inbound Filters, Connector Developers must implement this functionality into their Connectors.

Implementing Inbound Filters in your Connector

We'll use the scenario of receiving a product webhook event from Shopify to demonstrate how to implement Inbound Filter functionality in your Connector.

1. Receiving Webhook Data

First let's imagine your Connector receives a product webhook event from Shopify, by way of your webhook/product endpoint:

POSThttps://{my_connector_url}/webhook/product

The product webhook event sent to your Connector might contain the following data:

Headers
"x-shopify-shop-domain": "myshopifystore"
{
"id": 632910392,
"title": "Toaster",
"body_html": "<p>Four slice toaster.</p>",
"created_at": "2024-01-02T08:59:11-05:00",
"updated_at": "2024-01-02T08:59:11-05:00",
"status": "active",
"variants": [
{
"id": 808950810,
"product_id": 632910392,
"title": "Stainless Steel",
"price": "100.00",
"sku": "8082STAINLESS"
}
]
}

2. Constructing a Message

Next, we'll transform the data from the product webhook event into a structured Message:

{
"dataAction": "CREATE",
"integrationKey": "shopify_nz_integration",
"schemaName": "limber",
"schemaVersion": "2.1.0",
"shapeName": "Product",
"storeKey": "limber",
"mode": "LIVE",
"dataId": {
...
},
"data": {
...
}
}

3. Requesting Inbound Filter Information

Following that, we'll obtain the end-user defined filter settings for this Integration from SyncHive, utilizing the x-shopify-shop-domain from earlier as the tenant-id.

Call the SyncHive v1/integration endpoint as follows:

PUThttps://{synchive_api_url}/data-service/v1/integration
Headers
limber-connector: "{synchive_connector_key}"
tenant-id: "myshopifystore"
Content-Type: "application/json"

After submitting the request, you'll be provided with a JSON payload. Within this data, if the shapes array contains an inboundFilter whose inboundFilterStatus is ENABLED and the shapeName is Product, you can use these details to determine whether the Message meets the criteria to be sent to SyncHive or should be filtered out.

{
"shapes": [
{
"shapeName": "Product",
"inboundFilterStatus": "ENABLED",
"inboundFilter": "data.sku.toUpperCase() !== \"8082STAINLESS\".toUpperCase()",
...
}
],
"integration": {
...
},
"contact": {
...
},
}

4. Applying the Filter Logic

Finally, execute the JavaScript provided in the inboundFilter to assess if the Message meets the criteria for forwarding.

Following the evaluation of the filter logic:

  • If eligible: Proceed to send the assembled Message to SyncHive.
  • If not eligible: Send a event log to signal that the data was filtered and withhold it from being sent to SyncHive. Ensure this log clearly communicates to the end-user that the data was subjected to filtering.