Note: This topic is featured in the "Introduction to App Building" course in Tulip University.
When an operator presses a button that is running in an app on your shop floor, you will probably want to define some custom logic.
Triggers allow you to add logic to your app. You can use triggers to interact with devices, send alerts, communicate with backend systems, and more - all without writing a single line of code!
Triggers also allow you to update variables, which are a tool for tracking data within an app. You will want to understand variables before you use this article.
Types of Trigger Statements
You can use two types of commands in a trigger
Action: A change in the app that is not related to changing steps
Transition: Change steps or terminate the app in the Player
Here's what it looks like:
"Transitions" are events that can allow other triggers to fire. For example, you can create a trigger that fires every time that the app is completed.
Types of Triggers
There are three types of triggers that you can use in a regular step:
Button triggers are activated when a button is pressed. There can be multiple button triggers on a Step that are triggered when the respective button is pressed by an operator in the Tulip Player.
These can be accessed in the "Widget" menu in the Context Pane after selecting a button.
"Step triggers" are activated by these events:
at regular time intervals (“time fires”)
when there is an input from a machine or device (“machines & devices”).
when the step is opened (“step open”)
when the step is closed (“step close”)
These can be accessed via the Step tab in the Context Pane.
"Step open" and "step closed" triggers will fire when a button in the app has a transition that changes to a new step or restarts the app.
"App triggers" are activated by these events:
App is cancelled
They can be modified on the "App" tab of the Context Pane:
All of these triggers can be activated automatically on any step.
For example, if you have a "Complete" button on three different steps, the "App Completed" trigger can run on any of those steps.
Use Cases for Triggers
Some examples of common actions you can take with triggers include:
Navigating within the App: Use triggers to go to the next or previous step. Or, navigate to a specific step such as a "Call for Help" step.
Complete the App: to log the data from a run of the app.
Calling a connector function to access a back end system: Connectors can be used to enable Tulip to talk with third party systems. These connectors can be called from within Triggers. This allows you to push or pull data from Tulip into a back end system using variables.
Sending Alerts: You can also use triggers to send emails or SMS alerts to a relevant administrator. These messages can include images, status information about the process, and other relevant information.
Storing Data: If you want to store data within Tulip, you can use:
Variables: Data that is only relevant to one app
Tables: Use a Table to store data that will be used across multiple apps
You will use the "Data Manipulation", "Store" command in a "Then" statement to accomplish this.
Triggers work using a when, then logic structure:
when "event registers in Tulip"
then "take action" or "make transition".
A slightly more complex version of this logic is triggers with condition:
when "event registers in Tulip"
if "condition is met"
then "take action"
else "take a different action"
If you need to use "if/else" statements, check out this guide to triggers with conditions.
Events that drive actions can be simple things like a button press that causes the app to go to the next step.
Or, they can be more complex actions like a barcode scan that queries a backend database to return order information as a variable.
"Device" "Barcode Scannner" outputs at "this station"
"Run Connector Function" connector: "Example Database" "Order Lookup Multiline" barcode: "Device Output" "data" and save result as: "Variable" "Order Details"
"Go To Step" "Next"
Here's more detail on the "Then" statement:
This Trigger uses a barcode scanner to:
Retrieve Order Details from an external system,
Save value as a variable
Auto-advance to the next step.
For a list of all possible trigger actions and transitions, see this separate guide.
For a list of the top 10 most common triggers we see customers building with Tulip, check out this article, "What are the top 10 most common triggers in Tulip."
Did you find what you were looking for?
You can also head to community.tulip.co to post your question or see if others have faced a similar question!