Filters are used to apply basic transformations on an input array of JSON format. The Filter app can only be used on the template level. 

Filters are similar to adapters in functionality. However, instead of mapping Virtual Objects, they perform two different functions, reverse mapping of data between apps, and modifying prefixes/postfixes to keys and values. The details of these two methods will be discussed later in this document.

To use the Filter step, create a new template or open an already created template. Add a new step through the Add Step button as shown below.

You can find the filter step option in the list of available steps.

In the select app field, there is only one option, “Filters” that you can select. After that, you need to select the filter type as shown below.

  1. Reverse Mapping

When there is a two-way sync between apps in an integration, the data is transferred both ways. Normally the user provides you mapping of attributes in one direction between the apps. Reverse mapping allows you to map that data in the other direction as well. This maps all predefined as well as custom fields defined by user between both apps. For example, at the integration setup, the user might specify that the data from the “SMS” attribute of the first app goes in the “Phone” attribute of the second app. But when the data travels in the opposite direction, you need to provide the information for attributes for that direction as well, i.e. from the second app to the first app.

For a two-way sync integration to work, data or attributes that a user has stored for one app are mapped with the attributes of the other app. As an example, let’s say that you have created an integration of Mailchimp contacts in the Sendinblue app. When a user is setting up this integration, he will provide different attributes for a contact in MailChimp and map them with attributes of Sendinblue and that mapping will be stored in Sendinblue. This will make sure any updates to a contact in MailChimp will be reflected in Sendinblue. But if any updates are made to that contact in Sendinblue, they also need to reflect in MailChimp. For that, there will also be a need to store mapping for the reverse direction in MailChimp. This way, MailChimp will know the correspondence between the attributes that need to be updated for a contact.

Once you add the Reverse Map filter step, it will have the following fields that you can configure. 

Here are the details of the above fields:

  • JSON: The input array of JSON format that you want to apply reverse mapping on.
  • Prepend to keys: Add text in the beginning of any field name.
  • Remove from values: Remove the given text that is in the prefixes of field values.

If we see an example, following is the user-provided mapping stored in Sendinblue for a MailChimp contact.

{

"LASTNAME" : "{custom_fields.LNAME}",

"FIRSTNAME" : "{custom_fields.FNAME}",

“SMS”: “{custom_fields.PHONENUMBER}”

}

After reverse mapping, the above will look like this,

{

“LNAME”: “{contact.0.attributes.LASTNAME}”,

“FNAME”: “{contact.0.attributes.FNAME}”,

“PHONENUMBER”: “{content.0.attributes.PHONENUMBER}”

}

Along with reverse mapping , we also provided following values to the fields:

Prepend to keys: contact.0.attributes. (This gives the index and step number of where to get the contact attributes in the template).

Remove: custom_fields.

This will give us the final result, where the fields and their values are interchanged. This will map the contact’s attributes in Mailchimp with their values stored in Sendinblue. This mapping will then work in the direction of Sendinblue to Mailchimp.

  1. Adding Prefix to Values

This filter step allows you to add a text at the beginning of any field value of an input JSON object. This is different from reverse mapping because it does not switch the fields and their values. It only adds a prefix to the values of the fields.

The following fields can be configured in the Adding Prefix filter.

The prefix that you want to add before the field values can be given in the “AddPrefix” field above. In the Json string field, we can give an input array that has the mapped attributes like the one shown below.

{

"LASTNAME" : "{LNAME}",

"FIRSTNAME" : "{FNAME}",

“SMS”: “{PHONENUMBER}”

}

If we put the text “contact.0.attributes.” in the “AddPrefix” field, the resulting output will be as shown below.

{

"LASTNAME" : "{contact.0.attributes.LNAME}",

"FIRSTNAME" : "{contact.0.attributes.FNAME}",

“SMS”: “{contact.0.attributes.PHONENUMBER}”

}

The usage of filters makes our template creation process much easier for two-way sync integrations. Details about creating your own template can be found here.

Did this answer your question?