--- title: 'Trigger: Query pipeline feature' slug: '1458' canonical_url: https://docs.coveo.com/en/1458/ collection: tune-relevance source_format: adoc --- # Trigger: Query pipeline feature A [query pipeline statement](https://docs.coveo.com/en/236/) expressing the `trigger` [query pipeline feature](https://docs.coveo.com/en/234/) defines an action to execute in the [search interface](https://docs.coveo.com/en/2741/) from which a [query](https://docs.coveo.com/en/231/) originates. > **Important** > > If a statement expressing the `trigger` feature isn't associated with a [query pipeline condition](https://docs.coveo.com/en/2793/), it's ignored. The following `trigger` actions are available: * `execute` executes a custom JavaScript function call. * `notify` displays a message to the end [user](https://docs.coveo.com/en/250/). * `query` performs a new query. * `redirect` redirects the web browser to a specific URL. When a statement expressing the `trigger` feature is applied, an object representing the action to perform is generated inside the `triggers` property of the query response. The search interface from which the query originates is then responsible for translating this object into an action (for example, executing a corresponding JavaScript function call, notifying the end user with a corresponding message, etc.). > **Notes** > > * In the [Coveo Administration Console](https://docs.coveo.com/en/183/), you can manage statements expressing the `trigger` feature [from the **Triggers** subtab](https://docs.coveo.com/en/3413#access-the-triggers-subtab). > > * For usage in Headless/Atomic interfaces, see [Manage trigger rules](https://docs.coveo.com/en/3413/). > > * In a full [Coveo JavaScript Search Framework](https://docs.coveo.com/en/187/) interface, you use the `Triggers` component to automatically handle trigger actions. > With version [2.8521](https://docs.coveo.com/en/m54e5269#march-2020-release-v28521), standalone search boxes automatically handle `redirect` triggers without the need for a `Triggers` component. The following diagram shows the process of a query being sent to the Search API and the order of execution of query pipeline features. ![Coveo | diagram showing order of execution](https://docs.coveo.com/en/assets/images/coveo-platform/trigger-statements-diagram.svg) ## Syntax Use the following [query pipeline language (QPL)](https://docs.coveo.com/en/235/) syntax to define a statement expressing the `trigger` feature: ```text execute | notify | query | redirect ``` ### `` A string that contains the JavaScript function call to execute (for example, `myFunction()`). Boolean, integer, and quoted string function arguments are allowed. > **Note** > > When specifying a function containing arguments (for example, `myFunction(true, 123, "abc")`), the arguments aren't executed in the function as is. > The argument values are rather returned in an object as follows: > > ```javascript { element: div.CoveoTriggers, param1: true, param2: 123, param3: "abc" } ``` > > Therefore, the corresponding function must be implemented accordingly on client-side. > For example, if the trigger expression is `execute myFunction(true,123,"abc")`, the corresponding function could be configured as follows: > > ```javascript function myFunction(paramValues) { /* `paramValues` appear in an object: { element: div.CoveoTriggers, param1: true, param2: 123, param3: "abc" } */ alert("Hi, This is your answer: " + paramValues.param3); // paramValues.param3 is "abc" }; ``` ### `` A quoted string that contains a message to display to the end user (for example, `"Hello world!"`). ### `` A query expression to perform against the [index](https://docs.coveo.com/en/204/) (for example, `coveo OR "machine learning"`). ### `` A quoted string that contains a URL to which the browser is redirected (for example, `+"http://www.example.com"+`). ## Example You create a global condition with the following QPL definition: ```text when $query contains "trigger statement" ``` In an empty [query pipeline](https://docs.coveo.com/en/180/) named `Testing Triggers`, you create three distinct statements, each expressing the `trigger` feature, with the following QPL definitions: * **Statement 1:** ```text execute showAnimation("triggerStatement", 100, true) ``` * **Statement 2:** ```text notify "Here is some information about the `trigger` query pipeline feature!" ``` * **Statement 3:** ```text query `@title=="Trigger: Query pipeline feature"` ``` You associate each of these statements with the global condition you created. A user performs a query against your index with the following payload: ```json { "pipeline": "Testing Triggers", "q": "how do trigger statements work" } ``` This query goes through the `Testing Triggers` query pipeline and satisfies the condition of each statement in that pipeline, so all of the statements are applied. As a result, the `triggers` property of the query response is populated as follows: ```json [ { "type": "execute", "content": { "name": "showAnimation", "params": ["triggerStatement", 100, true] } }, { "type": "notify", "content": "Here is some information about the `trigger` query pipeline feature!" }, { "type": "query", "content": "@title==\"Trigger - Query pipeline feature\"" } ] ``` The search interface from which the query originated ensures that the corresponding actions are executed.