What are Triggers?
  • 30 Sep 2022
  • 10 Minutes to read
  • Contributors

What are Triggers?


Article summary

A brief overview of how to build logic into Tulip apps without writing any code.

Note

This topic is featured in the "Basic App Design and Logic" course in Tulip University.


In this article, you will learn:

  • What types of actions Triggers can execute.
  • What types of triggers exist, and how to leverage them.
  • Common usecases for Triggers

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

  1. Action: A change in the app that is not related to changing steps
  2. Transition: Change steps or terminate the app in the Player

Here's what it looks like:

What are Triggers_189549467

"Transitions" are events that can allow other triggers to fire. For example, you can create a trigger that fires every time the app is completed.

Types of Triggers

There are three types of triggers that you can use in a regular step:

Button Triggers

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 level Triggers

Step level 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 (“When step opened”)
  • When the Step is closed (“When step closed”)

These can be accessed via the Step Tab in the Context Pane.

More information about Step level Triggers available here

App Level Triggers

"App triggers" are activated by these events:

  • App starts
  • App completes
  • App is canceled

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:

  1. Variables: Data that is only relevant to one app
  2. 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.

Creating Triggers

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.

WHEN

  • "Device" "Barcode Scanner" outputs at "this station"

THEN

  • "Run Connector Function" connector: "Example Database" "Order Lookup Multiline" barcode: "Device Output" "data" and save the 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.

Further Reading

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!


Was this article helpful?