Scenario:

Imagine the scenario where you only want to take actions in an App Connect flow if an email address is from a real client, as opposed to someone internal to your own business. For example, I have a flow that’s triggered by a new MailChimp subscriber, but I only want to add the new subscriber to a Google Sheets spreadsheet if their email address doesn’t contain “ibm.com”.

Solution:

To achieve this level of filtering, you’ll need to use a JSONata function on the Mailchimp trigger’s EmailAddress field, as follows.

  1. Add an If node after your MailChimp event, and on the left side of the “if” expression, type “contains” to show the string functions that match: Screenshot showing how to select the $contains() expression
  2. Click the listed function to add the expression template to the left side of the expression: {{$contains(string, “chars”)}}.
  3. Define the parameters of the $contains function:
    1. Replace the “string” parameter of the expression by clicking Insert a reference Insert a reference icon and selecting the MailChimp “EmailAddress” field, and replace the “chars” parameter with “ibm.com”.
    2. Change the operator for the If expression to be “is false”.

    So the expression states that you’ll take a particular action for all subscribers with an email address that doesn’t contain “ibm.com”.
    Screenshot showing the full $contains() expression

  4. You can now add an application to the If node to take a specific action. For example, you can add a Google Sheets “Create row” action to the “if” branch, so that subscribers are added to your spreadsheet if they don’t have an email address with “ibm.com”. You could add another action to your “else” branch to deal with subscribers with an IBM email address.
    A flow with a MailChimp event and an If node that's defined by a function

You can do some powerful things with functions. For more information about the JSON query and transformation language, see http://jsonata.org/.

Join The Discussion

Your email address will not be published. Required fields are marked *