The Live Query Language allows Flex customers to get basic information about their Flex instance from Sync. Queries are written in infix notation in the form 'field [operator] "value"'. Only string types are supported for values.
The examples on this page use the Sync SDK.
Index name is a data class for which Live Queries are available. Currently, supported index names for Flex are: tr-task
, tr-worker
, tr-reservation
, tr-queue
.
The TaskQueue list may not include all TaskQueues if the TaskQueue has not been used for 30 days or more. Reset the expiration on your TaskQueue by routing an inbound task to the Queue. Each additional task and any transfers will reset the expiration time to 30 days.
Operator | Description | Alternative forms | Example |
---|---|---|---|
and | Logical AND operation. | and, AND, && | a == "b" AND c != "d" |
or | Logical OR operation. | or, OR, || | a == "b" OR c != "d" |
in | Evaluates whether an attribute's value matches an element (possibly many) from the given array. | in, IN | field IN ["value1", "value2"] |
eq | Checks if an attribute has a specified value. | eq, EQ, == | field EQ "value" |
not_in | Evaluates whether an attribute has any values other than those specified in the given array. | not_in, NOT_IN | field NOT_IN ["value1", "value2"] |
not_eq | Checks if an attribute has any values other than the given one. | not_eq, NOT_EQ, != | field NOT_EQ "value" |
contains | Checks if an attribute value string contains a substring | contains, CONTAINS | field CONTAINS "value" |
() | Start and end of evaluation block, determine operator precedence. | n/a | (field == "value" OR lang IN ["es", "en"]) AND team EQ "engineering" |
[] | Start and end of array block, enumerate a list of elements. | n/a | ["value1", "value2"] |
, | Comma is used to separate elements in array. | n/a | n/a |
"..." | Value of a string type must be double-quoted within the query expression. | n/a | n/a |
* Sync Client has a number of limits in place which will constrain certain query expressions. Please check Sync Client Limits page for more information.
1const SyncClient = require('twilio-sync');23syncClient.liveQuery('tr-worker', 'data.attributes.worker_name == "Bob"')4.then(function (args) {5console.log('Subscribed to live data updates for worker Bob');6let items = args.getItems();7Object.entries(items).forEach(([key, value]) => {8console.log('Search result item key: ' + key);9console.log('Search result item value: ' + value);10});11})12.catch(function (err) {13console.log('Error when subscribing to live updates for Bob', err);14});
As currently max response size is 200 records, the code example below will subscribe us to up to 200 workers.
1const SyncClient = require('twilio-sync');23syncClient.liveQuery('tr-worker', '')4.then(function (args) {5console.log('Subscribed to live data updates for workers');6let items = args.getItems();7Object.entries(items).forEach(([key, value]) => {8console.log('Search result item key: ' + key);9console.log('Search result item value: ' + value);10});11})12.catch(function (err) {13console.log('Error when subscribing to live updates', err);14});;