FME Version
Files
-
- 200 KB
- Download
Introduction
FME Workbench can be used to build a workspace that will check datasets or services for the desired outcome, changed values or values that meet certain criteria. These can then be run on a schedule with FME Flow (formerly FME Server).
If data is returned, change identified, or criteria met, the workspace can trigger events (subscriptions). This could be data processing or sending a notification.
In this tutorial we will be using the OpenWeatherMapForcaster to check the weather on a schedule and send an email notification with current weather conditions with an FME Flow automation about the current conditions.
This tutorial uses a custom transformer called OpenWeatherMapForecaster that uses an API. If the API no longer works or you are having trouble with the custom transformer after obtaining your own API key from OpenWeatherMap, please contact Safe Support.
Step-by-step Instructions
Part 1: Create the Workspace
1. Get API Key from OpenWeatherMap
In a web browser, sign up for an API key from OpenWeatherMap to use with the OpenWeatherMapForecaster transformer from the FME Hub.
2. Add a OpenWeatherMapForecaster Transformer
Open FME Workbench and add a Creator and the OpenWeatherMapForecaster transformer to the canvas. You may need to download and install the OpenWeatherMapForecaster transformer from the FME Hub if you haven’t already.
3. Create a Point Feature with the Creator
The OpenWeatherMapForecaster takes point geometry as input to return the weather forecast. Add latitude and longitude coordinates for a point of interest into the Creator as a Point Geometry Object. The longitude coordinate is the X value and the latitude coordinate is the Y value.
The Safe Software HQ coordinates in decimal degrees are 49.138036, -122.857629. You can also find your own coordinates using Google Maps.
4. Add API Key to OpenWeatherMapForecaster
Open the OpenWeatherMapForecaster, set the Weather to ‘Current’ and enter the API key obtained from OpenWeatherMap.
5. Run Workspace
Run the workspace and inspect the output from the OpenWeatherMapForecaster transformer. The transformer returns multiple different weather values as different attributes, which can be used to construct a notification message.
6. Add an FME Flow Automations Writer
Next, to be able to pass the attributes to the Email Action in an Automation, add an FME Flow Automations writer to the Weather output port of the OpenWeatherMapForecaster. Set the Feature Type Name to ‘Weather’. If you expand the writer, you’ll see all the attributes that are passed through it.
7. Publish Workspace to FME Flow
Publish the workspace to FME Flow. For detailed instructions on how to publish a workspace, see Publish a Workspace to FME Flow and Run It. Register the workspace with the Job Submitter service.
Part 2: Create the Automation
1. Create an FME Flow Automation with a Schedule Trigger
Open and log into FME Flow. Create an FME Flow Automation with a Schedule trigger set to the interval you’d like to receive weather updates. For example, if you want to receive a weather update for Safe HQ prior to deciding whether to go to the office or work from home each day, set the schedule to trigger weekdays at 7:15 am.
2. Add a Run Workspace Action
Add a Run a Workspace action to the FME Flow Schedule success port and configure it to run the Weather Updates workspace. This workspace doesn’t take any input parameters, although you could configure the coordinates input to the Creator in Step 3 to be input User Parameters. You can also see all the weather forecast attributes in Output Attributes > Weather > Event Attributes.
3. Add an Email External Action
Add an Email external action to the automation canvas and connect it to the ‘Weather’ output port of the workspace action. Configure the Email action with your SMTP connection information, your email to send the weather update to, and an email that it is sent from. See Send Email from Automations for additional information.
Add an Email Subject, such as ‘Safe HQ Weather Update’. Then open the Text Editor for the Email Body.
In the Text Editor, use the weather forecast attributes passed from the workspace under Workspace > Weather to customize a notification message to be emailed.
Select Validate and if successful, Apply the changes to the Email action.
4. Start Automation
Start the Automation and Trigger the schedule. Check your email for the Weather Update.
Additional Resources
Routing Data Between Workspaces with Automations
Tutorial: Getting Started with APIs
Comments
0 comments
Please sign in to leave a comment.