Run an Automation Using the Manual Trigger

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

In this tutorial, we’ll explore the manual trigger. This trigger gives users the ability to manually run an automation on-demand either via the Web UI or REST API in FME Flow (formerly FME Server). Optionally you can enter input JSON and simulate an incoming message as if it were from another trigger protocol. 

We’ll use the automation created in the Job Orchestration with Automations article as a starting point. This automation triggers two parallel workflows with different processing times, which then waits for both to complete, and proceeds as one unified process. We’ll replace the schedule with a manual trigger so that this series of tasks can easily be run on-demand, just like running a single workspace from the Run Workspace page. 

Alternatively, the manual trigger could be used in conjunction with another trigger type, making it easy to run manually on demand as well as in response to events in real-time. 
 

Step-by-step Instructions

1. Import Project

Please note that if you are importing the project as a non-admin user that you will need to have an admin grant permissions to the project and contents before proceeding. Please see Known Issue: Importing a fsproject File Requires an Admin to Grant Permissions to the Project for more information. 

  • If you are using FME Flow 2023.0 or newer, download the AutomationsManualTrigger_2023_1.fsproject
  • If you are using FME Server 2022.1 to 2022.2.5, download the AutomationsManualTrigger_2022_1.fsproject
  • If you are using FME Server 2021.0 to 2022.0, download the AutomationsManualTrigger_2021_0.fsproject. 


Once downloaded, log into FME Flow, expand Projects, and then click on Manage Projects. 
ExpandProjects.png

On the Projects page, click Import. On the Import page, upload the file, then click Import to finish uploading the project.  
Import.png
 
2. Add Manual Trigger
Once the project has been uploaded, go to Automations > Manage Automations, and open the Automations Manual Trigger Start automation. You should turn the guides off if you have them enabled. Click on Menu > Hide Guides. 
HideGuides.png

Once in the automation, click on the FME Flow Schedule component to open the parameters. Change the Trigger to Manual Trigger (max 1 per Automation). 
ChangeTrigger.png

FME Server 2021.0 or older 
If you are using FME Server 2021.0 or older, the Manual Trigger was a separate component. To add a Manual Trigger, click on the orange plus (+) button in the bottom left corner to open the components menu. Click on Manual Trigger, then drag and drop it onto the canvas. 
ManualTriggerManual.jpeg

Delete the FME Server Schedule component, then connect Manual Trigger to the Success Port (checkmark) to the Speedy Data run workspace component. Also, connect the Success port to the Longer Data workspace component. 
Workflow.png

3. Create Parameter
When the automation is manually triggered, a popup dialog will appear where input data can be entered that sends information to components downstream in the automation. Note that this popup dialog will only appear if Prompt for JSON on Trigger is enabled in the Manual Trigger parameters. 
Prompt.png

In this example, the Speedy Data workspace has an optional published parameter for users to enter a WHERE clause for a database reader, so let’s set this up to fetch input from the trigger.  

Depending on which version of FME Flow you are using, there are two different methods for creating a parameter. Both options work for FME 2022.1 or newer. If you are using a version older than FME 2022.1, use the Import Parameters from JSON method

Manual Parameters (formerly Manual Keys) Editor

In FME 2022.1, a new feature has been added to the Manual Trigger component, where the automation author can create type-specific manual parameters instead of only using JSON as an input. These type-specific parameters act the same as the JSON input and the values are used downstream in the automation. 

Note: Manual Keys were renamed to Manual Parameters in FME 2023.0. 

Let’s create a new parameter. Open the Manual Trigger parameters, then switch to the Output Attributes tab. Next, click on Manage to open the Manual Parameters Editor. 
ImportKeys.png

In the Manual Parameters Editor, click the drop-down arrow and then select Text as the parameter type. 
TextType.png

This editor is similar to the Published Parameters Manager in FME Workbench. On the right-hand side of the editor, enter the following parameters:

  • Parameter: fme_where
  • Prompt: WHERE clause
  • Required: Un-checked
  • Default Value (optional): SELECT * FROM AddressPoints

ManualWhereType.png

Click OK to close the editor. In the Manual Trigger parameters Under Success > Manual Parameters, there is now a parameter called manual.fme_where, click Apply to close the parameters. 
ManualWhere.png
 

Import Parameters from JSON

The following method can be used for all versions FME Flow 
When the automation is triggered, a popup dialog will give you the option to enter input JSON that can send information to components downstream in the automation. 
To set this up, open the Manual Trigger parameters, then switch to the Output Attributes tab. Click on the Import Parameters from JSON button to open the popup dialog. 
ManageKeys.png
 
In the popup dialog, enter:

{"fme_where":"SELECT * FROM AddressPoints;"}

Click Parse. 
JSON.png

Under Success > Manual Parameters, there is now a parameter called manual.fme_where. Click Apply to close the parameters. 
ManualWhere.png

4. Configure Workspace Action to Digest Parameters
The remainder of the tutorial is the same for both methods of creating the manual.fme_where output parameter. 

Open the Speedy Data workspace component parameters. Click the drop-down arrow next to the Database Reader Where Clause published parameter. From the drop-down, expand Manual Parameters, then select manual.fme_where. Click Apply. 
WorkspaceWhere.png
 
5. Save Automation and Trigger Automation Manually
Save the automation, and then start it.

There are three methods to trigger an automation:

a) From within the automation: 
Open the Manual Trigger parameters, then click Trigger.  Or click Trigger next to Stop Automation on the top menu bar. 
TriggerAuto.png
 
In the Trigger Automations popup dialog, click OK without entering a value, as the value was supplied when the manual.fme_where parameter was created. 
If the parameter was created using the Manual Parameters Editor, the value should be shown as the default value that was supplied. 
ManualParameterForm.png

b) From the automations list
In the list of automations, click the check box next to the automation you wish to trigger to select it. Then from the Actions drop-down, select Trigger Automation. 
AutomationsList.png
 
c) Trigger automation via REST API
To trigger an automation from the REST API, first copy the automation’s ID. To find the ID, go to the Automations page, then click on the Customize Columns button. In the Customize Columns dialog, move ID to the Displayed Columns section, then click OK. 
ExposeID.png

The ID column should now be shown. Copy the ID for the desired automation by clicking on the clipboard icon. 
CopyID.png

Once the ID is copied, navigate to the REST API documentation by clicking Help (?) > REST API in the top right corner of the Web UI. 
REstAPI.png
 
In the REST API documentation, click Get Token and enter your credentials to retrieve a testing token. This token is valid for one hour and should not be used for production. See Authorization in the FME Server REST API | Token Management for more information on tokens. 
GetToken.png

Next, select the API tab and expand the Automations endpoint to find:

POST /automations/workflows/<id>/trigger

EndPoint.png

Paste in the ID, then click Try it out. 
POST.png

That’s it, you can now trigger an Automation to run on demand. Note only a single Manual Trigger is supported per automation.
 

Additional Resources

Manual Trigger Documentation
 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.