Skip to main content

Built-in Functions

EnvRpadFalse
LenCheckDigitsTrue
GetCaptureNamesJsonString
GetOrAbsJsonParse
SortByStringRoundUrlJoin
SortByNumberFloorNow
SliceCeilTimestamp
ContainsMinTimeIn
SubstMaxTimeElapsed
ToLowercaseSqrtLocalDateTime
ToUppercasePowTruncTime
CaptureReSinTime
MatchReCosTimePart
SubstReTanNextTick
PrefixArcSinPnDoc
SuffixArcCosPnDocRef
JoinArcTanConversation
ArrayJoinAtan2ConversationId
SplitDeg2RadActor
WordRatioRad2DegActorId
MonetaryValuePiPeer
UuidRandomAuthor
LpadRandomInt

Env​

Env(name)

Returns the value of the environment variable with the given name, or NULL if none.

Len​

Len(value)

Returns the length of the given string, array or object (# of fields).

Get​

Get(value, index)

Gets the index out of value, if it exists. If value is an array, index must be a zero-based integer value. If value is an object, index must be a string. If index is not found in value, an error is returned.

GetOr​

GetOr(value, index, ..)

Gets the index out of value, if it exists. If value is an array, index must be a zero-based integer value. If value is an object, index must be a string. If index is not found in value, the optional 3rd argument is returned if given otherwise null.

SortByString​

SortByString(value, property)

Returns a copy of the given array sorted by the string value of the given property. An error is thrown if any element of the array does not have the property.

SortByNumber​

SortByNumber(value, property)

Returns a copy of the given array sorted by the numeric value of the given property. An error is thrown if any element of the array does not have the property or if the property is not a number.

Slice​

Slice(value, start)

Returns the substring of value from the start index to the end of string.

Slice(value, start, end)

Returns the substring of value from the start index up to but excluding the end index.

Contains​

Contains(expr, value)

Returns true if the expr contains value. For strings, this means the string contains the substring value. For arrays, this means one of the values inside the array matches. For objects, this means one of the keys exists in the object.

Subst​

Subst(substr, replacement, text)

Replace all occurrences of the given substr in text with the replacement.

ToLowercase​

ToLowercase(value)

Converts value as a string to lower case.

ToUppercase​

ToUppercase(value)

Converts value as a string to upper case.

CaptureRe​

CaptureRe(regex, text)

Matches text with the regular expression and returns the first capture group of matched. Returns false if not matched.

MatchRe​

MatchRe(regex, text)

Returns true of the text matches the regular expression

SubstRe​

SubstRe(regex, replacement, text)

Replaces all substrings of text that match the regular expression with replacement.

Prefix​

Prefix(text, separator)

Returns the substring of text from the beginning up to the first occurrence of separator.

Suffix​

Suffix(text, separator)

Returns the substring of text from just after the first occurrence of separator to the end of text.

Join​

Join(separator, ..)

Returns the concatenation of all arguments after separator with copies of separator in between.

ArrayJoin​

ArrayJoin(separator, array)

Returns the concatenation of all elements of array with copies of separator in between.

Split​

Split(text, regex)

Splits text at every substring matching the regular expression and returns an array of the resulting parts not including the matches.

WordRatio​

WordRatio(sentence1, sentence2)

Returns a similarity measure of two English sentences. It is the ratio of the number of common words to the total number of words.

MonetaryValue​

MonetaryValue(amount)

Parses a monetary amount given as a string and returns the value in cents. Ignores leading dollar sign.

Uuid​

Uuid()

Generates a version 4 UUID

Lpad​

Lpad(text, length, padding)

Left pads the text and return a string at least the requested length by prepending copies of padding.

Rpad​

Rpad(text, length, padding)

Right pads the text and return a string at least the requested length by appending copies of padding.

CheckDigits​

CheckDigits(text, length)

Returns the checksum of a string as a string of the requested length. The checksum result will be zero padded if less than length, or truncated on the left if more than length.

CaptureNames​

CaptureNames(regex, text)

Matches text with regular expression and returns named capture groups as an object. An empty object is returned if not matched.

Abs​

Abs(value)

Returns the absolute value of value

Round​

Round(value)

Returns the integer closest to value

Round(value, n)

Returns value rounded to n decimal places

Floor​

Floor(value)

Returns the greatest integer less than or equal to value

Ceil​

Ceil(value)

Returns the smallest integer greater than or equal value

Min​

Min(..)

Return the minimum value of all the arguments.

Max​

Max(..)

Return the maximum value of all the arguments.

Sqrt​

Sqrt(value)

Returns the square root of value

Pow​

Pow(x, y)

Returns the power of x to y

Sin​

Sin(value)

Returns the sine of value

Cos​

Cos(value)

Returns the cosine of value

Tan​

Tan(value)

Returns the tangent of value

ArcSin​

ArcSin(value)

Returns the arc-sine of value

ArcCos​

ArcCos(value)

Returns the arc-cosine of value

ArcTan​

ArcTan(value)

Returns the arc-tan of value

Atan2​

Atan2(y, x)

Computes the four quadrant arctangent of (y) and (x) in radians.

Deg2Rad​

Deg2Rad(angle)

Converts the angle in degrees to radians

Rad2Deg​

Rad2Deg(angle)

Converts the angle in radians to degrees

Pi​

Pi()

Returns the value of PI

Random​

Random()

Returns a number between 0 and 1, not including 1

RandomInt​

RandomInt(n)

Returns a random number between 0 and n, not including n

False​

False()

Returns false

True​

True()

Returns true

JsonString​

JsonString(value)

Returns the JSON representation of a value

JsonParse​

JsonParse(json)

Parses a JSON string and returns the value

UrlJoin​

UrlJoin(url, path)

Returns the url joined with path

Now​

Now()

Returns the current date/time as a string in ISO (RFC3339) format

Timestamp​

Timestamp()

Returns the current number of seconds since January 1, 1970 0:00:00 UTC

TimeIn​

TimeIn(delta)

Returns the current date/time + delta as a string in ISO (RFC3339) format where delta is a duration

TimeElapsed​

TimeElapsed(t1, t2)

Returns the time elapsed between the date/times t1 and t2 in milliseconds (integer), where t1/t2 are in ISO (RFC3339) format

TimeElapsed(t1, t2, unit)

Returns the time elapsed between the date/times t1 and t2 in the given unit (real number) where unit is a duration and t1/t2 are in ISO (RFC3339) format

LocalDateTime​

LocalDateTime(datetime, timezone)

Returns local date/time in a given timezone of a ISO (RFC3339) formatted date/time

TruncTime​

TruncTime(datetime)

Returns the ISO (RFC3339) formatted time date/time truncated to time=00:00:00

Time​

Time(hour, minute)

Returns a time value at the given hour/minute

Time(hour, minute, second)

Returns a time value at the given hour/minute/second

TimePart​

TimePart(datetime)

Returns the UTC time of a ISO (RFC3339) formatted time date/time

TimePart(datetime, timezone)

Returns local time of a ISO (RFC3339) formatted date/time

NextTick​

NextTick()

Returns earliest date/time greater than now with seconds resolution

PnDoc​

PnDoc(descriptor)

Create a Paranet document object that can be passed to a sidecar process

PnDocRef​

PnDocRef(descriptor)

Create a Paranet document reference object that can be passed to a sidecar process

Conversation​

Conversation()

Get the conversation ID of the skill request context

Conversation(select)

Get the conversation ID of the current handler if select == "current" or the skill request context if select == "outer"

ConversationId​

ConversationId()

Retreives the ID portion of a conversation. This is equivalent to Get(Split(Conversation(), "@"), 0).

Actor​

Actor()

Returns the id and version (<actor-id>@version) of the running actor. Available from tasks and skill/observation declarations' body and handlers.

ActorId​

ActorId()

Returns the id (without version) of the running actor. Available from tasks and skill/observation declarations' body and handlers.

Peer​

Peer()

Returns the id (without version) of the actor (or federated node) that made the skill request. Available from skill declaration's body and handlers.

Author​

Author()

Returns the id and version (<actor-id>@version) of actor (or federated node) that sent the observed skill request/message. Available from observation declaration's body and handlers.