Reading the docs, you would be led to believe that creating Fredhopper triggers was a matter of editing the trigger-types.xml file. It is however also possible to do this programatically – a trick that can come in handy should you not have access to that file on Production, or you wish to manage your triggers through automation.
The SmartTarget developers have created some handy helper classes:
com.tridion.smarttarget.triggers.TriggerTypesHelper – Can be used to create/retrieve Trigger Types
com.tridion.smarttarget.utils.LocalizationHelper – Can be used to manage Trigger Labels – the display text you see in the SmartTarget UI when selecting a value
In my implementation I actually packaged a JSP page up with the deployer war file (which already had the required SmartTarget configuration files needed for the SmartTarget API), which we call manually on every environment to create new triggers.
The URL parameters which should be added when requesting the JSP are as follows:
name – The trigger name
urlParam – The trigger url parameter
type – (Optional) The trigger type : text (default), number, date or boolean
values – (Optional) For triggers where the values are selected from a list, a comma delimited list of values
labels – (Optional) For triggers where the values are selected from a list, a comma delimited list of display values
multi – (Optional) When true (default is false) The trigger type is created as multiselect
In the future we might hook into the CMS, so we could, for example create a trigger type based on a category in Tridion (using the keyword keys as the trigger values, and title/descriptions as the trigger value labels) via a GUI extension (Category right click -> Sync Trigger Type). This would be the last step in removing IT involvement in trigger management.