Data Query

Data Query

The DataQuery step type is used to query data from the any of the custom data tables you have configured for the agent.

Options

data_model_name

Or it can be the machine_name of one of the custom data schemas that are loaded in your account.

query

The query that will be performed on the database. This will be an object matching the format described below in then “Query Format” section

Output

objects

A list of all the objects then that were returned by the query.

Properties

type

system

needs conversation

[optional]

uses content template

true

uses options template

true

customizable output schema

false

Query Format

Queries to the system must be in the form of a JSON object matching the following schema

TableQuery

[startRow]

If there are too many entries to return, this allows you to specify the start row when paging through multiple pages.

 

Default is 0.

[endRow]

This allows you to specify the last row to retrieve. or null to retrieve all rows.

Default to null.

[filterModel]

This is an object that maps field names to TableQueryFilter objects that describe the filtering to be done.

 

Default is an empty object, or no filters.

[sortModel]

This is a list that contains TableSortModel objects describing the sorting to be done.

 

Default is to sort by created_at if nothing else is specified

TableSortModel

colId

The name of the field that is being sorted on.

sort

The direction of the sort. Must be either asc or desc

TableFilterModel

filterType

The type of filter to be applied. Must be one of text, number, date, join, or set

type

The type of operation to be performed on the data. Must be one of:

empty, equals, notEqual, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual, inRange, contains, notContains, startsWith, endsWith, blank, notBlank, AND, OR

filter

This is the value to be used in the filter operation

filterTo

When applying range queries, this is the second value in the query. E.g. you will get all data in-between the value of filter and filterTo

dateFrom

When filterType is date, this will work similarly to filter in that it provides the first value used in the comparison operation

dateTo

When filterType is date, this will work similarly to filterTo in that it provides the second date that we will fetch data between for range queries

conditions

When filter type is join, this provides a list of TableFilterModel objects which will be either AND’d or OR’d together

values

When filter type is set, this provides a list of values that will be exact matched to when looking up the data.

Examples Queries

Example 1 - Finding a record by email address

This will query the contacts table for all entries that match one of two specific email addresses.

{ "data_model_name": "contact", "query": { "startRow": 0, "endRow": null, "filterModel": { "email_address": { "filterType": "set", "values": ["test@prosperalabs.ai", "cool@example.com"] } }, "sortModel": [] } }

Example 2 - 10 records between specific dates, sorted by name

{ "data_model_name": "contact", "query": { "startRow": 0, "endRow": 10, "filterModel": { "created_at": { "filterType": "date", "type": "inRange", "dateFrom": "2025-01-01", "dateTo": "2025-01-28" } }, "sortModel": [ { "colId": "name", "sort": "asc" } ] } }