Manage Trigger Rules

Members with the required privileges can use query pipeline triggers to define an action to execute in a search interface when a query meets the associated condition.

The list of query pipeline triggers for a Coveo organization is empty by default.

When a trigger rule 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 (e.g., executing a corresponding JavaScript function call, notifying the end user with a corresponding message, etc.).

In a full Coveo JavaScript Search Framework interface, you use the Triggers component to automatically handle trigger actions. Since the March 2020 Release (v2.8521), standalone search boxes automatically handle Redirect triggers without the need for a Triggers component.

Create Trigger Rules

  1. On the Query Pipelines page, click the query pipeline in which you want to add a rule, and then in the Action bar, click Edit Components.

  2. On the page that opens, select the Advanced tab.

  3. In the Advanced tab, on the left-hand side of the page, select Triggers.

  4. In the upper-right corner of the page, click Add Rule to access the Add a Trigger Rule [1] subpage.

  5. Under Type, select one of the available methods (Notify, Query, Execute, or Redirect).

  6. In the box that opens, depending on the selected method, enter the desired value.

  7. On the right-hand side, under Condition, select a query pipeline condition in the drop-down menu or create a new one.

    If a trigger rule isn’t associated with a query pipeline condition, the rule is ignored.

  8. Under User note, optionally enter information that will help you manage the rule in the future.

  9. Click Add Rule.

Edit Trigger Rules

  1. On the Query Pipelines page, click the query pipeline in which you want to edit a rule, and then in the Action bar, click Edit Components.

  2. On the page that opens, select the Advanced tab.

  3. In the Advanced tab, on the left-hand side of the page, select Triggers.

  4. Click the rule you want to edit, and then in the Action bar, click Edit [2] to access the Edit a Trigger Rule subpage.

  5. Under Type, select one of the available methods (Notify, Query, Execute, or Redirect).

  6. In the box that opens, depending on the selected method, enter the desired value.

  7. On the right-hand side, under Condition, select a query pipeline condition in the drop-down menu or create a new one.

    If a trigger rule isn’t associated with a query pipeline condition, the rule is ignored.

  8. Under User note, optionally enter information that will help you manage the rule in the future.

  9. Click Save.

Duplicate Trigger Rules

  1. On the Query Pipelines page, click the query pipeline for which you want to duplicate query pipeline rules, and then in the Action bar, click Edit components.

  2. On the page that opens, select the Advanced tab.

  3. In the Advanced tab, on the left-hand side of the page, select Triggers.

  4. In the Triggers subtab, click the rule you want to duplicate within the same pipeline (typically to create a slightly different rule).

  5. In the Action bar, click Duplicate.

The duplicated rule appears at the bottom of the list in the pipeline component tab.

Delete Trigger Rules

  1. On the Query Pipelines page, click the query pipeline for which you want to delete query pipeline rules, and then in the Action bar, click Edit components.

  2. On the page that opens, select the Advanced tab.

  3. In the Advanced tab, on the left-hand side of the page, select Trigger.

  4. In the Trigger subtab, click the rule you want to delete.

  5. In the Action bar, click More, and then select Delete.

  6. Click Delete to confirm.

Change the Rule Order

Query pipeline rules are executed in the order in which they appear on the page until a condition is satisfied.

  1. On the Query Pipelines page, click the query pipeline for which you want to manage the rules' execution order, and then in the Action bar, click Edit components.

  2. On the page that opens, select the Advanced tab.

  3. In the Advanced tab, on the left-hand side of the page, select Triggers.

  4. In the Triggers subtab, click the rule whose position you want to change.

  5. In the Action bar, click Move up or Move down to change the position of the rule.

Reference

Methods

When managing trigger rules, you can select one of the following trigger types:

Notify

When creating or editing a Notify trigger rule, in the String box, enter a message to display in the search interface.

EXAMPLE

On your internal search page for parts, each time a query is performed without a model number, you want to show Add a model number to your query to the user.

Query

When creating or editing a Query trigger rule, in the Query box, enter a query to perform as a new search in the search interface.

This method can be used as a custom Did You Mean feature or a thesaurus.

Execute

When creating or editing an Execute trigger rule, in the Function box, enter a JavaScript function to execute in the user’s browser.

EXAMPLES
  • A user searches webcam. Since this query can refer to any model, you create a function to generate a carousel of webcams each time webcam is queried, and then let the user select the one they’re looking for.

  • You want a box to appear ath the top of the search results when users search for the name of a product. This box contains a download link and links to the product documentation guides.

Admin-TriggerEx

Redirect

When creating or editing a Redirect trigger rule, in the URL box, enter a URL to redirect the user.

EXAMPLE

For certain queries, you always want a specific web page to be opened. A user searching find stores is automatically redirected to your Store Finder page instead of being shown search results that contain the phrase find stores.

QPL Syntax

Use the following query pipeline language (QPL) syntax to define a trigger rule:

execute <function> | notify <message> | query <expression> | redirect <url>

<function>

A string that contains the JavaScript function call to execute (e.g., myFunction(true, 123, "abc")).

Boolean, integer, and quoted string function arguments are allowed.

<message>

A quoted string that contains a message to display to the end user (e.g., "Hello world!").

<expression>

A query expression to perform against the index (e.g., coveo OR "machine learning").

<url>

A quoted string that contains a URL to which the browser is redirected (e.g., "http://www.example.com").

Order of Execution

The following diagram highlights in orange the position of trigger rules in the overall order of execution of query pipeline features.

Apply trigger rules

Required Privileges

By default, members of the Administrators and Relevance Managers built-in groups can view and edit elements of the Query Pipelines page.

The following table indicates the required privileges to view or edit elements of the Query Pipelines page (see Manage Privileges and Privilege Reference).

Action Service - Domain Required access level

View trigger

Search - Query pipelines

View

Edit trigger

Search - Query pipelines

Edit


1. (Advanced) You can click Menu, and then select Add rule with code to define the rule using the appropriate QPL syntax.
2. (Advanced) You can click More, and then select Edit code to edit the rule using the appropriate QPL syntax.
Recommended Articles