COTLang Guide
Esta página aún no se encuentra traducida al español.
Overview
COTLang is a scripting language created by Cotalker, primarily used in its routines. It is used to extract data from different contexts in Cotalker.
COTLang Commands
When setting up routine stages, COTLang can be used for getting information from Cotalker databases.
Below is a table with COTLang commands, their descriptions, and format:
$VALUE#[EXTRACTOR]
$OUTPUT#[stage-name]#[EXTRACTOR]
$ENV# environment-var
$CODE#[model]#[EXTRACTOR]#[INPUT]
$JOIN#[Some char to join]#[ARG A]#[ARG B]#...#[ARG N]
$$TIME#[PARAM1]#[PARAM2]
$META#[EXTRACTOR]
Token values:
- Values: Dive into value.
- Operators: Apply function to current data.
Examples
META
question.display =
["$META#somekey"]
message.meta = '
{"somekey":"Happy New Year"}'
When a value is required, question.display should return
["$META#somekey"]
EXTRACTOR
Operators:
... |[find => identifier = keyname]|... | [TOKEN1]|[TOKEN2]|...|[TOKEN-N]
General Example:
{a: { b: { c1: 'Hola', c2: 'Mundo' } } }
To access the info of variable c1, use the following token:
a|b|c1
. It wil respond withHola
.
Function
[ function_name => token = Syntax | token ]
The following list shows the available COTLang functions along with a brief description and example:
$VALUE#array|[size=>*]
$VALUE#anyValue|[cast=>parseFloat]
$VALUE#populatedChannelUsers|[map=>email]
$VALUE#data|[arrayToObject=>key=value]...
Return only values that are not 0, "", null or undefined.
$VALUE#data|[isDefinedFilter=>meta]
$VALUE#data|[filter=>contentType=application/vnd.cotalker.survey+text]
$VALUE#data|[notEqualFilter=>contentType=application/vnd.cotalker.survey+text]
$VALUE#data|[simpleNotEqualFilter=>125938f23295sd0]
$VALUE#data|[simpleEqualFilter=>125938f23295sd0]
$VALUE#data|[find=>identifier=minuta-fecha]
$VALUE#populatedChannelUsers|[map=>email]|[push=>string=ignacio@cotalker.com]
$VALUE#populatedChannelUsers|[map=>email]|[add=>string=ignacio@cotalker.com]
Perform a mathematical operation on the values. The operation ar add or subtract.
$VALUE#answer|anyNumber|[math=>add=2]
$VALUE#createdAt|[date=>format=DD-MM-YYYY]
Perform the operation on each element of the array. The operator can be >= x, > x, < x, <= x or === x. And the key are gte, gt, lt, lte or eq, respectively.
$VALUE#data|[filter=>contentType=application/vnd.cotalker.survey+textnumber]|[map=>responses]|[every=>lte=2]
Return the values that apply to one of the following conditions: >= x, > x, < x, <= x or === x. And the key are gte, gt, lt, lte or eq, respectively.
$VALUE#data|[filter=>contentType=application/vnd.cotalker.survey+textnumber]|[map=>responses]|[some=>lte=2]
$VALUE#populatedChannelUsers|[json=>parse]
$VALUE#someValue|[querystring=>string]
$VALUE#answer_data|[cotanswer_list=>array]
$VALUE#path|to|string|[gencode=>*]