Snippet Triggers can be used to perform an action without showing Alfred, simply by typing a pre-set text keyword in any text field on your Mac.
How Can I Use Snippet Triggers?
- To run a script that adds "Good morning!", "Good afternoon!" or "Good evening!" to a snippet before pasting depending on time of day.
- To select a quote from a pre-defined list before pasting your email signature
Using a Snippet Trigger
To add a snippet trigger, right-click on the workflow canvas to pop up the objects menu and, under Triggers, choose Snippet.
To configure the snippet trigger, set a keyword. Keep in mind that you'll need to type the prefix followed by your keyword. By default, the Shared Prefix is set to \\ with no Suffix set.
For example, in the screenshot above, typing \\thanks would run the snippet trigger set above.
You can change the Shared Prefix and Suffix, but keep in mind that this is shared across all of your Snippet Triggers, so it's best to use the default or set a clear and useful one from the start.
Focused App Variable
If you exclusively want the snippet to trigger in a specific application, check the box for the Focused App Variable, and add the relevant app's bundle ID.
Considerations about Snippet Triggers
Stripping snippet keywords on import
When importing a new workflow, snippet triggers are stripped, as well as hotkeys. This ensures that the snippet triggers you set are relevant and useful for you, and don't clash with existing snippets or keywords you've already set.
As such, you'll need to double-click to view the configuration of the Snippet object, and set it to your own trigger keywords.
Conflicting keywords with snippets
You can also use snippets-based actions in the Snippet text auto-expansion feature, so it's possible to create a snippet trigger object that conflicts with an existing snippet keyword.
Workflows always take precedence when a keyword is used both in a trigger object and in a text snippet. In other words, if you set the same keyword in a snippet for auto-expansion AND in a snippet trigger object, the workflow will take precedence and the conflict will only appear in red in the Snippets feature preferences, where you'll be able to change the keyword.
We recommend using a prefix for your Snippet Triggers that is sufficiently different to your snippet keywords that these won't accidentally conflict.