---
source_url: https://www.pubnub.com/docs/analytics/decisions/create-predefined-query
title: Create a query from a predefined template
updated_at: 2026-09-30T07:20:08.000Z
---

# Create a query from a predefined template

## Documentation index

To discover more PubNub resources:

1. Fetch [PubNub's llms.txt](https://www.pubnub.com/llms-full.txt) for a list of available pages in Markdown format.
2. Identify relevant URLs from that index.
3. Fetch the target pages.

Do not assume a path exists, always check the index first.

This guide shows you how to create a Query Builder query from a predefined template and run it to view results.

:::tip Preview
Query Builder is in preview. Features and functionality may change.
:::

## Before you start

Before starting, confirm you have:

* Access to Illuminate in the [Admin Portal](https://admin.pubnub.com/).
* At least one [Business Object](https://www.pubnub.com/docs/analytics/decisions/business-objects.md). An active Business Object shows data immediately. An inactive one shows no data until activated.

For an overview of predefined query types, filter options, and how queries connect to Decisions, see [Query Builder](https://www.pubnub.com/docs/analytics/decisions/query-builder.md).

## Configure the query

1. In the [Admin Portal](https://admin.pubnub.com/), go to **Illuminate > Business Objects**.
2. At the top of the Business Objects page, click **New query**. The predefined query templates appear.
3. Choose one of the templates: **Top N**, **Bottom N**, **Cross-posting spam**, or **Chat flooding spam**.
4. Enter a name for your query. Add an optional description.
5. Click **Select Business Object** and choose a Business Object from the list.

   After you select a Business Object, the query preselects the data fields that best match the template. The typical fields are User, Channel, and Message Text.

   For **Top N** and **Bottom N** queries, you can adjust the ranking criteria. The default is count of records. You can switch to count of a specific data field, or to average, sum, max, or min of a number field.

6. Set the **Time period** for the aggregation window, for example `last 1 minute`, `last 10 minutes`, or `last 1 hour`.
7. Click **Save**.

## Add filters

Optionally, add filters to narrow results before running the query.

1. Click **Add filter**.
2. Select the field to filter on.
3. Choose a comparator and enter a value.
4. Repeat for each additional filter.

For the full list of available comparators, see [Query Builder](https://www.pubnub.com/docs/analytics/decisions/query-builder.md).

## Run the query

1. Click **Run**.

Query Builder executes the query and displays results. Each row represents a condition that can trigger an action when you connect this query to a Decision.

:::tip No data appears
Extend the time window, for example to `1 hour` or more, and click **Refresh** to run the query again. Do not save the extended window unless that is the aggregation window you want to use.
:::

After verifying results, you can adjust filters and run again, or connect the query to a Decision. See [Create a Decision from a query](https://www.pubnub.com/docs/analytics/decisions/create-decision-from-query.md).

Last updated at: 2026-09-30T07:20:08.000Z
