How to add business logic with content-based router

How to add business logic with content-based router

To explain the usage of our content-based router that enables you to add some business logic to your integration flow, let’s imagine that I have received a Google Spreadsheet file with unsorted leads data, for example, from downloading a coupon on a website. To convert these leads to customers, I’d like to offer them something of interest with a specifically targeted campaign based on the country of residence. For that, I need to filter and split the list.

So, the first thing I would need to do is to get access to the original file with unsorted data. I take the very first entry as a sample for configuring the later steps.

Now, as a next step, I select the Content-based Router. It sends information this or that way – or in the platform terms, down this or that branch – based on specific conditions. I want to get all US residents first, so this will be what my first branch is about. If I open the setup tab, I’ll see the sample data received from the previous step – my original file – and a field where I will need to enter my conditions. To do that, you’ll need to spend a bit of time with JSONata – the powerful transformation language that we use in our platform. Fear not, though, it is fairly easy to understand. So, with my simple condition, I want to get only the people who live in the United States. And I can see that I wrote my condition correctly since the result based on my sample is “true”.

Now I set up the next branch. This one will target all European countries. It’s the same setup, so we are not spending too much time of our video on it. The only difference is in the condition – you can see that it is longer as there are quite a few countries we need to include.

Next, I want to send this data to appropriate Spreadsheet files. Equally, I could have sent it, for example, directly to a MailChimp list or any other marketing application. I have already prepared blank lists to fill with data, so in the next steps, I just need to define these lists in my connector setup. Now, in the “values” section, I can specify which data exactly from the original file I want to have. In my case, I want it all, so this is what I will enter here.

Now let’s finish this step and configure the second step – from the other branch of our Content-based Router. As we remember, we want to have a second list with only European residents. So, we proceed in the same way as we did with the Spreadsheet for US residents.

After we publish the draft and start the flow, let’s watch how my blank tables are filled with the filtered data in real time.