Triggers
A trigger is a mechanism by which an external event may cause a flow to be invoked.
When a flow is invoked with a trigger its Inputs
will contain two extra pieces of information:
[eu.sirenia]Manatee.In.Trigger
will contain the type of the trigger[eu.sirenia]Manatee.In.TriggerParams
will contain any parameters the trigger may provide (see below for examples)
Adding a trigger to a flow
A trigger can be added to a flow in the Settings tab for a flow.
The trigger will activate on all Manatees on which it is possible to run the flow (controlled via the groups of the flow and the application that contains the flow).
External triggers
External triggers are all triggers that are external to the Manatee but are still events on the local machine.
Window
The window trigger can launch a flow based on whether a matching window is shown or hidden.
Configurable parameters
Event
which window-event to use (‘shown’ or ‘hidden’)Title
the title which the window must haveClass
the class of the window frameCloseWindow
whether or not to immediately close the detected window
Parameters to flow
The trigger type is WINDOW
.
title
the actual title of the detected windowhwnd
the window handlekind
the kind of event (window ‘shown’ or ‘hidden’)className
the class of the window framecloseWindow
whether or not the window was closed
The parameters are serialized as a JSON object.
File-system
The filesystem trigger can monitor a directory for files that are either added, removed or changed.
Configurable parameters
Directory
the directory to monitorMatch
a regular expression which filters the files that will be used to trigger the flow
Parameters to flow
The trigger type is FILESYSTEM
.
file
the acual file that caused the trigger to fireeventType
the type of event (‘CREATED’, ‘CHANGED’, ‘RENAMED’ or ‘DELETED’)
The parameters are serialized as a JSON object.
Cron
The cron trigger can launch a flow on a certain time-schedule.
Configurable parameters
The trigger is configured with a cron string which specifies a schedule with which to fire the flow. The UI in Cuesta tries to be helpful in explaining when a trigger will fire as you type in the components of the cron string.
Parameters to flow
The trigger type is CRON
.
cronString
the cron string which triggered the flow
The parameters are serialized as a JSON object.
Hotkey
The hotkey trigger can launch a flow when the user hits a matching keyboard combo.
A valid combo must include at least one modifier key and one other key, e.g. ctrl+r
is valid, while r
is not.
Configurable parameters
modifierKeys
a set of modifier keys the user must presskeys
a set of keys the user must press while the modifier keys are pressed
Parameters to flow
The trigger type is HOTKEY
.
modifierKeys
the set of modifier keys the user pressedkeys
the set of keys the user pressed
Keyboard
The keyboard trigger listens for fast keyboard input matching a given regular expression. The match-value of the first group in the regex is given as input to the flow. If you have any subgroups in your trigger regular expression then you need to wrap the whole regular expression in paranthesis to form the first group. E.g. you’re using this trigger for keyboard wedge configured barcode scanners and your raw input is something like: {OEM1}d01029284{NUMPAD0}{NUMPAD8}21982798{NUMPAD0}
. In order to be resistant to keyboard layout changes you can then construct a regular expression:
.*d\d{8}(\{[^\}].+\})+\d{8}(\{[^\}].+\})+
But since the first group will match the {NUMPADN}
elements, then that is the input given to the flow. This can then be fixed by adding an initial group:
.*d(\d{8}(\{[^\}].+\})+\d{8}(\{[^\}].+\})+)
This trigger is most useful with devices such as scanners that can be configured to act as keyboards. The trigger will hold the input characters in a buffer for a short (while) and trigger a flow if the input buffer contains a matching sequence of characters. The input itself is not blocked and will end where the window focus is.
Configurable parameters
match
the regular expression which the input buffer must matchlookbackMs
the number of milliseconds the input buffer will contain the characters
Parameters to flow
The trigger type is KEYBOARD
.
match
the value of the matching string, either the first group in the regular expression or the complete match if it does not contain any groups
Table
The table trigger is used to fire flows when a table is modified.
Configurable parameters
table
which table to look for changes to
Parameters to flow
The trigger type is TABLE
.
tableId
the id of the changed tabletableName
its name
Event intercept triggers
The event intercept trigger can launch a flow when the user clicks a given field.
Configurable parameters
eventType
is the type of the intercept (LEFTCLICK
orRIGHTCLICK
)fieldId
is the identifier of the field to intercept events on
Parameters to flow
The trigger type is INTERCEPT
.
eventType
is the type of the intercept (LEFTCLICK
orRIGHTCLICK
)fieldId
is the identifier of the field to intercept events onfieldName
is the name of the field clickedfieldPath
is the configured path of the element clicked
Context triggers
The trigger type is CONTEXT
.
Context triggers are triggers which will fire a flow once the shared context matches the preconditions for the trigger.
Context change
Run a flow whenever a subject in the shared context changes a value matching the configured properties of the trigger.
Configurable parameters
subject
the subject to matcholdValue
the old value to match (regular expression, default is empty which matches all values)newValue
the new value to match (regular expression, default is empty which matches all values)
Parameters to flow
The trigger type is CONTEXT
.
subject
the subject of the matching context itemoldValue
the previous value of the context itemnewValue
the new value of the context item
Lifecycle triggers
Lifecycle triggers are coupled with the lifecycle of the application.
Application attached
The trigger will fire as soon as the application is attached to a session. It can be used as a kind of initializer. It does not have any configurable parameters or provides any meaningful input to a flow except the type of the event; LIFECYCLE
and the param ATTACHED
along with the application which was the cause of the trigger.
Application detached
This trigger will fire when the application selected is detached (also happens when the application itself exits).
Manatee started
When Manatee starts it will trigger any flows with this trigger – this can also be used to start an application as Manatee will start an application before running any of its flows.
Browser navigation
This trigger will fire when an attached browser-based application is navigated to a matching url. Both a from and a to url matching regex must be configured.
Triggers from services
Mail
The mail trigger will trigger a flow whenever one or more mails matching the configured preconditons are received. It must be configured with the mail service (which in turn contains server connection details).
Only unread mails can trigger a flow and as soon as a trigger runs it will mark the mail as read. This ensures that the same flow (on the same machine) does not run multiple times on the same mail. In general the same principle applies across machines, but it is not guaranteed.
Configurable parameters
service
the mail service to connect tofromAddress
the address to match with the sender of the mail (regular expression)toAddress
the address to match with the recipient of the mail (regular expression)ccAddress
the address to match with the (cc) recipient of the mail (regular expression)subject
the subject to match (regular expression)body
the body to match (regular expression)attachments
the attachments to match (regular expression)
Parameters to flow
from
the senders addressto
the recipient addresscc
the cc addresssubject
the subjectbody
the bodyattachments
the attachments
Serial port
The serial port trigger will trigger a flow whenever a message is received from the device, which matches the trigger message pattern.
Configurable parameters
Serial port
the port to monitor for messagesMessage pattern
the pattern to match incoming messages against (regular expression). Note that this trigger is currently limited to matching inbound data interpreted as text according to the encoding selected in the chosen serial port service. For devices with binary protocols, this may make the regular expressions a bit harder to write. To match the byte sequence0x02 0x06 0x03
, the regular expression\x02\x06\x03
can be used. For binary protocol devices, the encoding selector in the serial port service should be left empty.
Parameters to flow
message
the matched message as a string
Previous messages
The serial port service keeps track of the most recently received messages from the device. Through this mechanism a flow can inspect the messages received prior to the triggering message. Details and examples can be seen in the service document.
Message queue (MQ)
The message queue trigger will trigger a flow whenever one or more messages matching the configured preconditions are received. Each MQ trigger must be set up to use an MQ service.
Configurable parameters
Message queue
the MQ service subscription to monitor for messagesMessage pattern
the pattern to match incoming messages against (regular expression).Claim pattern
the pattern to match the JWT token of incoming messages against (regular expression). This makes it possible to authenticate the origin of incoming messages before letting them trigger a flow. Obtain a valid token by contacting sirenia support.Reply expected
whether to reply to the sender of a triggering message with the result of the flow invocation or not. This enables manatee to function as a kind ofRemote Procedure Call
server.
Parameters to flow
message
the body of the triggering message
Code extracting the triggering message:
var triggerParams = JSON.parse(Inputs['[eu.sirenia]Manatee.In.TriggerParams']);
var triggeringMessage = triggerParams.message;
Debug.showDialog(triggeringMessage);
Chat trigger
The chat trigger will execute a flow whenever a matching message is detected.
Configuration properties
channel
a regex to match the channel to trigger onfrom
a regex to match the authortext
a regex to match the actual content of the message
Parameters to flow
The flow triggered by a chat message will get the triggering message in its params.:
text
the content of the messageuser
the user id of the author of the messageusername
the username of the authorchannel
the name of the channel in which the message was sentts
a timestamp/identifier for the message
See the service documentation for a detailed list of services.