Triggers tell DuckDuckGo on which search queries to initiate an Instant Answer. There are two types of triggers, words and regex.
The two types of triggers cannot be combined, but you may consider a third option of Regex Guards. We insist that you use word triggers whenever possible as they are simpler and faster.
Word triggers specify what to look for, and where to look for it:
triggers <location> => <array of words and phrases>
For example:
triggers start => "stackoverflow", "stack overflow", "SO";
You may find the qw function convenient:
@triggers = qw(john jacob jingleheimer schmidt);
triggers any => @triggers;
You can also use multiple trigger statements together:
triggers start => "tv", "television";
triggers end => "schedule", "hours";
start
— Word exists at the start of the queryend
— Word exists at the end of the querystartend
— Word is at the beginning or end of the queryany
— Word is anywhere in the query
Note: You can combine several trigger statements if, for example, you want certain words or phrases to be startend but others to be start. The Average Goodie demonstrates the usage of multiple Word trigger statements.
We insist that you use word triggers whenever possible as they are simpler and faster.
Note that you cannot combine the use of Regex Triggers with Word Triggers.
Regex triggers specify which version of the query, and a regular expression to apply.
triggers <query_format> => <regular expression>
triggers query_lc => qr/trigger (?:my|your|our) instant answer/;
or
my $regex = qr/^this is an? instant answer regexp$/;
triggers query_raw => $regex;
query_raw
— The query in its original form, with whitespace and case preservedquery
— Uniformly whitespaced version ofquery_raw
query_lc
— Lowercase version ofquery
query_nowhitespace
—query
with all whitespace removedquery_clean
—query_lc
, but with whitespace and non-alphanumeric ASCII removed
We have plans to make it possible to trigger Instant Answers in many different languages. Until an internationalization mechanism is place, to uphold maintainability and consistency, we cannot accept pull requests that add languages directly in the code.