There are scenarios where you need to know the distance between two specific cities and use it in your flows. Now you can easily do it using this new flow action. Grab an unmanaged package here, install it to you Salesforce organization and add it to your flow. Alternatively, you can grab the source code from GitHub and push to your org.
Internally this action utilizes Google Maps API so you will need to get developer key. You can request one here. After you got the key and installed the package, go to Setup -> Custom Metadata Types -> Google API Key (click ‘Manage Records‘ next to it). There will be just one record of this type: open it and paste your developer key into Key field.
Configuring Google developer key
The configuration is pretty straightforward: give it two cities (optionally with country names for disambiguity) and use the output distance measured in miles or kilometers.
Input values configuration
Output values configuration
If everything is fine parameter Is Success will contain True value. Otherwise, it becomes False, and Error Message will contain detailed description of the error (e.g. source or destination were not found or there are no routes between them). The distance (both in miles and in kilometers) are rounded up to 3 digits.
Example of the message constructed from the output parameters
Source Location and Destination Location output parameters are the source and destination input parameters converted to a universal form City, State, Country (e.g. Los Angeles, CA, USA)