Microsoft Flow & Logic App Conditions

 

Microsoft Flow & Logic Apps are a service for automating workflow across the growing number of apps and SaaS services that business users rely on. It’s similar to other web automation tools like ITTT or Zapier. Have a look at the Microsoft Flow blog for more information – https://flow.microsoft.com/en-us/blog/

Flow vs. Logic Apps

This section is taken from here and is provided as a way to give background information only…. The similarity of Microsoft Flow and Azure Logic Apps is that they are both configuration-first integration services, which makes it easy to build processes and workflows and integrate with various SaaS and enterprise applications.

    • Flow is built on top of Logic Apps
    • They have the same workflow designer
    • Connectors that work in one can also work in the other

Flows empowers any office worker to perform simple integrations (e.g. get SMS for important emails) without going through developers or IT. On the other hand, Logic Apps can enable advanced or mission-critical integrations (e.g. B2B processes) where enterprise-level DevOps and security practices are required.

The following table helps you determine whether Flow or Logic Apps is best for a given integration.

Flow Logic Apps
Audience Office workers, business users IT pros, developers
Scenarios Self-service Mission-critical
Design Tool Mobile Apps & In-browser UI only In-browser and Visual Studio, Code view available
DevOps Ad-hoc, develop in production source control, testing, support, and automation and manageability in Azure Resource Management
Admin Experience https://flow.microsoft.com https://portal.azure.com
Security Standard practices: data sovereignty, encryption at rest for sensitive data, etc. Security assurance of Azure: Azure Security, Security Center, audit logs, and more.

With both Microsoft Flow & Logic Apps, there’s such a thing called conditions. Conditions are like rules you add to your flow to dynamically decide on the outcome on a particular Flow. There are a number of different condition statements you can add into your flow. Conditions are like ‘IF‘ statements and you have the choice of the following flow conditions:

  • @contains(”, ”)
  • @not(contains(”, ”))
  • @equals(”, ”)
  • @not(equals(”, ”))
  • @greater(”, ”)
  • @greaterOrEquals(”, ”)
  • @less(”, ”)
  • @lessOrEquals(”, ”)
  • @startsWith(”, ”)
  • @not(startsWith(”, ”))
  • @endsWith(”, ”)
  • @not(endsWith(”, ”))

You could have multiple condition statements one after the other in Flow using the GUI, however it’s much better grouping Microsoft Flow conditions using ‘IF‘ or ‘AND‘ statements.

Below I give you some examples to get you started, once you have some examples, you can follow your nose from here on. But be careful with the use of brackets when grouping your conditions! You need to make sure the brackets are in the right spots.

I have used here RSS feeds as an example.

 

‘OR’ Statements

What if you wanted to monitor an RSS feed for new posts with two conditions using an ‘OR‘ statement? If the feed Summary contained the word ‘Azure‘ or if the Feed Title contained the word ‘Azure‘.

This is how you would do it:

@or(contains(triggerBody()?['title'], 'Azure'), contains(triggerBody()?['summary'], 'Azure'))

Another example is for a specific YouTube channel, if I wanted to use two conditions using an ‘OR‘ statement. I can configure a Microsoft Flow condition for if the YouTube title contained a specific word or if the YouTube description contained a specific word.

This is how I would do it:

@or(contains(triggerBody()?['snippet']?['title'], 'Azure'), contains(triggerBody()?['snippet']?['description'], 'Azure'))

‘AND’ Statements

What if you wanted to monitor an RSS feed for new posts with two conditions using an ‘AND‘ statement? If the language was ‘English‘ and if the Feed Title contained the word ‘Azure‘.

This is how you would do it:

@and(contains(triggerBody()?['title'], 'Azure'), equals(body('Detect_language')?['Name'], 'English'))

‘AND’ & ‘OR’ statements grouped together

What if you wanted to monitor an RSS feed with three conditions with a mix of ‘OR‘ and ‘AND‘ statements? You would group the statements like this below, I have first grouped an ‘OR‘ statement and then wrapped an over arching ‘AND‘ statement around all of it.

This is how it looks:

@and(or(contains(triggerBody()?['title'], 'Azure'), contains(triggerBody()?['summary'], 'Azure')), equals(body('Detect_language')?['Name'], 'English'))

URL Shortening

What if you wanted to shorten a URL to make it better to post things on Twitter for example? It is possible to shorten URLs using Microsoft Flow or Logic Apps. You just need to sign up for a free Bitly account https://bitly.com/ and then integrate Bitly with Microsoft Flow or Logic Apps by verifying your account.

Flow_Bitly

You can then use the shortened URL for services such as Twitter to help mitigate the character limitation of tweets – the number of letters.

More Info for URL shortening.

Azure

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: