Expressions Reference
abs(number)
Returns the absolute value of a number
Example 1:
When used as a Stack expression it returns a value of type Integer: 1
.
card MyCard do
my_var = abs(-1)
# When used in a piece of text prefix it with an `@`
my_var = "@abs(-1)"
end
and(argument1, argument2, argument3)
Returns true
if and only if all its arguments evaluate to true
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
when used with the following context:
%{"contact" => %{"age" => 32, "gender" => "?"}}
card MyCard do
my_var = contact.gender = "F" and contact.age >= 18
# When used in a piece of text prefix it with an `@`
my_var = "@and(contact.gender = \"F\", contact.age >= 18)"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
when used with the following context:
%{"contact" => %{"age" => 32, "gender" => "F"}}
card MyCard do
my_var = contact.gender = "F" and contact.age >= 18
# When used in a piece of text prefix it with an `@`
my_var = "@and(contact.gender = \"F\", contact.age >= 18)"
end
char(code)
Returns the character specified by a number
> "As easy as @char(65), @char(66), @char(67)"
"As easy as A, B, C"
Example 1:
When used as a Stack expression it returns a value of type String: "A"
.
card MyCard do
my_var = char(65)
# When used in a piece of text prefix it with an `@`
my_var = "@char(65)"
end
clean(binary)
Removes all non-printable characters from a text string
Example 1:
When used as a Stack expression it returns a value of type String: "ABC"
when used with the following context:
%{"value" => <<65, 0, 66, 0, 67>>}
card MyCard do
my_var = clean(value)
# When used in a piece of text prefix it with an `@`
my_var = "@clean(value)"
end
code(code_ast)
Returns a numeric code for the first character in a text string
> "The numeric code of A is @CODE(\"A\")"
"The numeric code of A is 65"
Example 1:
When used as a Stack expression it returns a value of type Integer: 65
.
card MyCard do
my_var = code("A")
# When used in a piece of text prefix it with an `@`
my_var = "@code(\"A\")"
end
concatenate(argument1, argument2, argument3)
Joins text strings into one text string
> "Your name is @CONCATENATE(contact.first_name, \" \", contact.last_name)"
"Your name is name surname"
Example 1:
When used as a Stack expression it returns a value of type String: "name surname"
when used with the following context:
%{"contact" => %{"first_name" => "name", "last_name" => "surname"}}
card MyCard do
my_var = concatenate(contact.first_name, " ", contact.last_name)
# When used in a piece of text prefix it with an `@`
my_var = "@concatenate(contact.first_name, \" \", contact.last_name)"
end
count(term)
Return the number of entries in a list, string, or a map.
Example 1:
When used as a Stack expression it returns a value of type Integer: 1
when used with the following context:
%{"map" => %{"foo" => "bar"}}
card MyCard do
my_var = count(map)
# When used in a piece of text prefix it with an `@`
my_var = "@count(map)"
end
Example 2:
When used as a Stack expression it returns a value of type Integer: 3
.
card MyCard do
my_var = count("zoë")
# When used in a piece of text prefix it with an `@`
my_var = "@count(\"zoë\")"
end
Example 3:
When used as a Stack expression it returns a value of type Integer: 3
.
card MyCard do
my_var = count([1, 2, 3])
# When used in a piece of text prefix it with an `@`
my_var = "@count([1, 2, 3])"
end
cull_data()
Permanently deletes all messages, contacts, contact details, attachments, and everything else related to a chat.
Example 1:
When used as a Stack expression it returns a complex Boolean type of default value:
true
with the following fields:
- type of type String.
card MyCard do
my_var = cull_data()
# When used in a piece of text prefix it with an `@`
my_var = "@cull_data()"
end
date(year, month, day)
Defines a new date value
Example 1: Construct a date from year, month, and day integers
When used as a Stack expression it returns a value of type Date: "2022-01-31"
when used with the following context:
%{"day" => 31, "month" => 1, "year" => 2022}
card MyCard do
my_var = date(year, month, day)
# When used in a piece of text prefix it with an `@`
my_var = "@date(year, month, day)"
end
datetime_add(datetime, offset, unit)
Calculates a new datetime based on the offset and unit provided.
The unit can be any of the following values:
- "Y" for years
- "M" for months
- "W" for weeks
- "D" for days
- "h" for hours
- "m" for minutes
- "s" for seconds
Specifying a negative offset results in date calculations back in time.
Example 1: Negative offsets
When used as a Stack expression it returns a value of type DateTime: "2020-02-28T00:00:00.000000Z"
.
card MyCard do
my_var = datetime_add(date(2020, 02, 29), -1, "D")
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_add(date(2020, 02, 29), -1, \"D\")"
end
Example 2: Leap year handling outside of a leap year.
When used as a Stack expression it returns a value of type DateTime: "2021-03-01T00:00:00.000000Z"
.
card MyCard do
my_var = datetime_add(date(2021, 02, 28), 1, "D")
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_add(date(2021, 02, 28), 1, \"D\")"
end
Example 3: Leap year handling in a leap year.
When used as a Stack expression it returns a value of type DateTime: "2020-02-29T00:00:00.000000Z"
.
card MyCard do
my_var = datetime_add(date(2020, 02, 28), 1, "D")
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_add(date(2020, 02, 28), 1, \"D\")"
end
Example 4: Calculates a new datetime based on the offset and unit provided.
When used as a Stack expression it returns a value of type DateTime: "2022-08-31T00:00:00Z"
when used with the following context:
%{"datetime" => ~U[2022-07-31 00:00:00Z], "offset" => "1", "unit" => "M"}
card MyCard do
my_var = datetime_add(datetime, offset, unit)
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_add(datetime, offset, unit)"
end
datetime_next(desired_day, time, base_date)
Calculates a new datetime based on a base date, a desired day and a desired time.
Example 1: If the day of the week is the same as the base date, the next occurrence is 7 days later.
When used as a Stack expression it returns a value of type DateTime: "2023-02-09T10:30:00-03:00"
when used with the following context:
%{"base_date" => ~U[2023-02-02 20:18:03Z], "contact" => %{"whatsapp_id" => "552197295926"}}
card MyCard do
my_var = datetime_next("thursday", "10:30", base_date)
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_next(\"thursday\", \"10:30\", base_date)"
end
Example 2: Shifts a datetime to the next occurrence of a given day of the week and a set time.
When used as a Stack expression it returns a value of type DateTime: "2023-02-06T10:00:00-03:00"
when used with the following context:
%{"base_date" => ~U[2023-02-03 20:18:03Z], "contact" => %{"whatsapp_id" => "552197295926"}}
card MyCard do
my_var = datetime_next("monday", "10:00", base_date)
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_next(\"monday\", \"10:00\", base_date)"
end
datetime_next(desired_day, time)
Calculates a new datetime based on today's date and time, a desired day and a desired time.
Example 1:
When used as a Stack expression it returns a value of type DateTime: "2023-08-26T13:45:00-03:00"
when used with the following context:
%{"contact" => %{"whatsapp_id" => "552197295926"}}
card MyCard do
my_var = datetime_next("saturday", "13:45")
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_next(\"saturday\", \"13:45\")"
end
datevalue(date, format)
Converts date stored in text to an actual date object and
formats it using strftime
formatting.
It will fallback to "%Y-%m-%d %H:%M:%S" if no formatting is supplied
Example 1: Convert a date value and read the date field
When used as a Stack expression it returns a value of type Date: "2022-01-01"
.
card MyCard do
my_var = datevalue(date(2022, 1, 1)).date
# When used in a piece of text prefix it with an `@`
my_var = "@datevalue(date(2022, 1, 1)).date"
end
Example 2: Convert a date from a piece of text and read the date field
When used as a Stack expression it returns a value of type Date: "2022-01-01"
.
card MyCard do
my_var = datevalue("2022-01-01").date
# When used in a piece of text prefix it with an `@`
my_var = "@datevalue(\"2022-01-01\").date"
end
Example 3: Convert a date from a piece of text to a formatted date string
When used as a Stack expression it returns a complex String type of default value:
"2022-01-01 00:00:00"
with the following fields:
- date of type Date.
card MyCard do
my_var = datevalue("2022-01-01")
# When used in a piece of text prefix it with an `@`
my_var = "@datevalue(\"2022-01-01\")"
end
datevalue(date)
day(date)
Returns only the day of the month of a date (1 to 31)
Example 1: Getting today's day of the month
When used as a Stack expression it returns a value of type Integer: 22
.
card MyCard do
my_var = day(now())
# When used in a piece of text prefix it with an `@`
my_var = "@day(now())"
end
Example 2: Getting today's day of the month
When used as a Stack expression it returns a value of type Integer: 10
.
card MyCard do
my_var = day(date(2022, 9, 10))
# When used in a piece of text prefix it with an `@`
my_var = "@day(date(2022, 9, 10))"
end
edate(date, months)
Moves a date by the given number of months
Example 1: Move the date store in a piece of text by 1 month
When used as a Stack expression it returns a value of type Date: "2022-11-10"
.
card MyCard do
my_var = edate("2022-10-10", 1)
# When used in a piece of text prefix it with an `@`
my_var = "@edate(\"2022-10-10\", 1)"
end
Example 2: Move the date in a date object by 1 month
When used as a Stack expression it returns a value of type DateTime: "2022-02-01T00:00:00Z"
when used with the following context:
%{right_now: ~U[2022-01-01 00:00:00Z]}
card MyCard do
my_var = edate(right_now, 1)
# When used in a piece of text prefix it with an `@`
my_var = "@edate(right_now, 1)"
end
filter(enumerable, filter_fun)
Filters a list by returning a new list that contains only the
elements for which filter_fun
is truthy.
Example 1:
When used as a Stack expression it returns a value of type List with values String, String: [
"B",
"B"
]
.
card MyCard do
my_var = filter(["A", "B", "C", "B"], & &1 == "B")
# When used in a piece of text prefix it with an `@`
my_var = "@filter([\"A\", \"B\", \"C\", \"B\"], & &1 == \"B\")"
end
find(enumerable, find_fun)
Finds the first element in the list for which filter_fun
is truthy.
Example 1:
When used as a Stack expression it returns a value of type List with values String, String: [
"Hi",
"World"
]
.
card MyCard do
my_var = find([["Hello", "World"], ["Hi", "World"]], & &1[0] == "Hi")
# When used in a piece of text prefix it with an `@`
my_var = "@find([[\"Hello\", \"World\"], [\"Hi\", \"World\"]], & &1[0] == \"Hi\")"
end
find_exact_match(input, keyword_set)
Find if there is an exact match to keyword set. The keywords may be numbers.
Example 1:
When used as a Stack expression it returns a value of type String: "apple"
.
card MyCard do
my_var = find_exact_match("apple", ["apple", "orange", "beets"])
# When used in a piece of text prefix it with an `@`
my_var = "@find_exact_match(\"apple\", [\"apple\", \"orange\", \"beets\"])"
end
find_fuzzy_matches(input, keyword_threshold_set)
Find the fuzzy matches to the keyword_threshold set. Each keyword has its own threshold.
Example 1:
When used as a Stack expression it returns a complex String type of default value:
"apple"
with the following fields:
- match of type String
- others of type List with values Map
- threshold of type Integer.
card MyCard do
my_var = find_fuzzy_matches("appls", [["apple", 1], ["app", 2]])
# When used in a piece of text prefix it with an `@`
my_var = "@find_fuzzy_matches(\"appls\", [[\"apple\", 1], [\"app\", 2]])"
end
find_fuzzy_matches(input, keyword_set, threshold)
Find the fuzzy matches to the keywords using the same threshold for all keywords
Example 1:
When used as a Stack expression it returns a complex String type of default value:
"pear"
with the following fields:
- match of type String
- others of type List with values
- threshold of type Integer.
card MyCard do
my_var = find_fuzzy_matches("pork", ["apple", "orange", "pear"], 3)
# When used in a piece of text prefix it with an `@`
my_var = "@find_fuzzy_matches(\"pork\", [\"apple\", \"orange\", \"pear\"], 3)"
end
first_word(binary)
Returns the first word in the given text - equivalent to WORD(text, 1)
Example 1:
When used as a Stack expression it returns a value of type String: "foo"
.
card MyCard do
my_var = first_word("foo bar baz")
# When used in a piece of text prefix it with an `@`
my_var = "@first_word(\"foo bar baz\")"
end
fixed(number, precision)
Formats the given number in decimal format using a period and commas
> You have @fixed(contact.balance, 2) in your account
"You have 4.21 in your account"
Example 1:
When used as a Stack expression it returns a value of type String: "3.80"
.
card MyCard do
my_var = fixed(3.7979, 2)
# When used in a piece of text prefix it with an `@`
my_var = "@fixed(3.7979, 2)"
end
Example 2:
When used as a Stack expression it returns a value of type String: "3.80"
.
card MyCard do
my_var = fixed(3.7979, 2, false)
# When used in a piece of text prefix it with an `@`
my_var = "@fixed(3.7979, 2, false)"
end
Example 3:
When used as a Stack expression it returns a value of type String: "4,000.4242"
.
card MyCard do
my_var = fixed(4000.424242, 4, true)
# When used in a piece of text prefix it with an `@`
my_var = "@fixed(4000.424242, 4, true)"
end
Example 4:
When used as a Stack expression it returns a value of type String: "4.21"
.
card MyCard do
my_var = fixed(4.209922, 2, false)
# When used in a piece of text prefix it with an `@`
my_var = "@fixed(4.209922, 2, false)"
end
fixed(number, precision, no_commas)
get_brief(phrase)
Extract the first few characters of the utterance, defaults to 20 characters
Example 1:
When used as a Stack expression it returns a value of type String: "this is a very lo..."
.
card MyCard do
my_var = get_brief("this is a very long sentence")
# When used in a piece of text prefix it with an `@`
my_var = "@get_brief(\"this is a very long sentence\")"
end
get_brief(phrase, num_chars)
Extract the first few characters of the utterance until the limit specified
Example 1:
When used as a Stack expression it returns a value of type String: "this is..."
.
card MyCard do
my_var = get_brief("this is a very long sentence", 10)
# When used in a piece of text prefix it with an `@`
my_var = "@get_brief(\"this is a very long sentence\", 10)"
end
get_collected_data()
Retrieves the data related to the current session such as processed messages, contact details and number information.
Example 1:
When used as a Stack expression it returns a value of type String: "{\"contacts\":[{\"profile\":{\"name\":\"John Doe\"},\"wa_id\":\"1234567890\"}],\"messages\":[{\"text\":{\"body\":\"hi\"}},{\"image\":{\"caption\":\"What is your name?\"},\"type\":\"image\"},{\"text\":{\"body\":\"user message\"}}],\"thread\":{\"contact\":{\"name\":\"John Doe\"}}}"
.
card MyCard do
my_var = get_collected_data()
# When used in a piece of text prefix it with an `@`
my_var = "@get_collected_data()"
end
get_write_results_data()
Get the flow results captured for the current contact in the current stack.
Example 1:
When used as a Stack expression it returns a value of type String: "{\"chat\":\"current chat...\",\"contact\":\"current contact...\",\"number\":\"current number...\",\"results\":[{\"question\":\"the question...\",\"question_id\":\"question unique-id...\",\"response\":\"the response...\",\"response_metadata\":\"the response metadata...\"}],\"session\":\"current session object...\",\"stack\":\"current stack...\"}"
.
card MyCard do
my_var = get_write_results_data()
# When used in a piece of text prefix it with an `@`
my_var = "@get_write_results_data()"
end
google_connect(service_account)
Connect with Google's APIs using the service account provided.
Example 1: The first argument is the service account for Google as a String. Please refer to Google's documentation on how to create a service account.
When used as a Stack expression it returns a value of type String: "an-api-access-token"
.
card MyCard do
my_var = google_connect("service-account-details")
# When used in a piece of text prefix it with an `@`
my_var = "@google_connect(\"service-account-details\")"
end
google_read_sheet(token, spreadsheet_id, sheet_name, cache_ttl)
Read a single sheet from a spreadsheet hosted by Google Docs
Example 1: The first argument is a token for authenticating with Google with.
This is the token returned by the google_connect()
function.
The last argument is how long to cache the results for, expressed in milliseconds.
When used as a Stack expression it returns a value of type Map: {
"error": null,
"properties": {
"title": "the sheet name"
},
"status": 200,
"values": [
[
"row-1 column-1 value",
"row-1 column-2 value"
],
[
"row-2 column-1 value",
"row-2 column-2 value"
]
]
}
.
card MyCard do
my_var = google_read_sheet("the-token", "the google sheet-id", "the sheet name", 10_000)
# When used in a piece of text prefix it with an `@`
my_var = "@google_read_sheet(\"the-token\", \"the google sheet-id\", \"the sheet name\", 10_000)"
end
Example 2: When a connection fails, one can inspect the HTTP status and the error to help in decision making on how best to proceed.
When used as a Stack expression it returns a value of type Map: {
"error": "connection timeout",
"status": null
}
.
card MyCard do
my_var = google_read_sheet("the-token", "the google sheet-id", "the sheet name", 10_000)
# When used in a piece of text prefix it with an `@`
my_var = "@google_read_sheet(\"the-token\", \"the google sheet-id\", \"the sheet name\", 10_000)"
end
has_all_words(haystack, words)
Tests whether all the words are contained in text
The words can be in any order and may appear more than once.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_all_words("the quick brown FOX", "red fox")
# When used in a piece of text prefix it with an `@`
my_var = "@has_all_words(\"the quick brown FOX\", \"red fox\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_all_words("the quick brown FOX", "the fox")
# When used in a piece of text prefix it with an `@`
my_var = "@has_all_words(\"the quick brown FOX\", \"the fox\")"
end
has_any_word(haystack, words)
Tests whether any of the words are contained in the text
Only one of the words needs to match and it may appear more than once.
Example 1:
When used as a Stack expression it returns a complex Boolean type of default value:
false
with the following fields:
- match of type Null.
card MyCard do
my_var = has_any_word("The Quick Brown Fox", "yellow")
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_word(\"The Quick Brown Fox\", \"yellow\")"
end
Example 2:
When used as a Stack expression it returns a complex Boolean type of default value:
true
with the following fields:
- match of type String.
card MyCard do
my_var = has_any_word("The Quick Brown Fox", "fox quick")
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_word(\"The Quick Brown Fox\", \"fox quick\")"
end
has_beginning(text, beginning)
Tests whether text starts with beginning
Both text values are trimmed of surrounding whitespace, but otherwise matching is strict without any tokenization.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_beginning("The Quick Brown", "quick brown")
# When used in a piece of text prefix it with an `@`
my_var = "@has_beginning(\"The Quick Brown\", \"quick brown\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_beginning("The Quick Brown", "the quick")
# When used in a piece of text prefix it with an `@`
my_var = "@has_beginning(\"The Quick Brown\", \"the quick\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_beginning("The Quick Brown", "the quick")
# When used in a piece of text prefix it with an `@`
my_var = "@has_beginning(\"The Quick Brown\", \"the quick\")"
end
has_date(expression)
Tests whether expression
contains a date formatted according to our environment
This is very naively implemented with a regular expression.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_date("there is no date here, just a year 2017")
# When used in a piece of text prefix it with an `@`
my_var = "@has_date(\"there is no date here, just a year 2017\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_date("the date is 15/01/2017")
# When used in a piece of text prefix it with an `@`
my_var = "@has_date(\"the date is 15/01/2017\")"
end
has_date_eq(expression, date_string)
Tests whether expression
is a date equal to date_string
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_date_eq("there is no date here, just a year 2017", "2017-01-15")
# When used in a piece of text prefix it with an `@`
my_var = "@has_date_eq(\"there is no date here, just a year 2017\", \"2017-01-15\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_date_eq("the date is 15/01/2017", "2017-01-15")
# When used in a piece of text prefix it with an `@`
my_var = "@has_date_eq(\"the date is 15/01/2017\", \"2017-01-15\")"
end
has_date_gt(expression, date_string)
Tests whether expression
is a date after the date date_string
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_date_gt("the date is 15/01/2017", "2017-03-15")
# When used in a piece of text prefix it with an `@`
my_var = "@has_date_gt(\"the date is 15/01/2017\", \"2017-03-15\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_date_gt("the date is 15/01/2017", "2017-01-01")
# When used in a piece of text prefix it with an `@`
my_var = "@has_date_gt(\"the date is 15/01/2017\", \"2017-01-01\")"
end
has_date_lt(expression, date_string)
Tests whether expression
contains a date before the date date_string
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_date_lt("the date is 15/01/2021", "2017-03-15")
# When used in a piece of text prefix it with an `@`
my_var = "@has_date_lt(\"the date is 15/01/2021\", \"2017-03-15\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_date_lt("the date is 15/01/2017", "2017-06-01")
# When used in a piece of text prefix it with an `@`
my_var = "@has_date_lt(\"the date is 15/01/2017\", \"2017-06-01\")"
end
has_email(expression)
Tests whether an email is contained in text
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_email("i'm not sharing my email")
# When used in a piece of text prefix it with an `@`
my_var = "@has_email(\"i'm not sharing my email\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_email("my email is foo1@bar.com, please respond")
# When used in a piece of text prefix it with an `@`
my_var = "@has_email(\"my email is foo1@bar.com, please respond\")"
end
has_group(groups, uuid)
Returns whether the contact is part of group with the passed in UUID
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
when used with the following context:
%{"contact" => %{"groups" => [%{"uuid" => "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d"}]}}
card MyCard do
my_var = has_group(contact.groups, "00000000-0000-0000-0000-000000000000")
# When used in a piece of text prefix it with an `@`
my_var = "@has_group(contact.groups, \"00000000-0000-0000-0000-000000000000\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
when used with the following context:
%{"contact" => %{"groups" => [%{"uuid" => "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d"}]}}
card MyCard do
my_var = has_group(contact.groups, "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d")
# When used in a piece of text prefix it with an `@`
my_var = "@has_group(contact.groups, \"b7cf0d83-f1c9-411c-96fd-c511a4cfa86d\")"
end
has_member(list, item)
Return true if a list has the given item as a member
Example 1: Check whether the given list has the item as a member
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_member(["A", "B", "C"], "C")
# When used in a piece of text prefix it with an `@`
my_var = "@has_member([\"A\", \"B\", \"C\"], \"C\")"
end
has_number(expression)
Tests whether expression
contains a number
Example 1:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number("0.6")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number(\"0.6\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number("٠.٥")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number(\"٠.٥\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number("العدد ٤٢")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number(\"العدد ٤٢\")"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number("the number is 42 and 5")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number(\"the number is 42 and 5\")"
end
has_number_eq(expression, float)
Tests whether expression
contains a number equal to the value
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_eq("four hundred", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_eq(\"four hundred\", \"foo\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_eq("the number is 40", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_eq(\"the number is 40\", \"foo\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_eq("the number is 40", "42")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_eq(\"the number is 40\", \"42\")"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_eq("the number is 42.0", "42")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_eq(\"the number is 42.0\", \"42\")"
end
Example 5:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_eq("the number is 42", "42")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_eq(\"the number is 42\", \"42\")"
end
Example 6:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_eq("the number is 42", 42.0)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_eq(\"the number is 42\", 42.0)"
end
Example 7:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_eq("the number is 42", 42)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_eq(\"the number is 42\", 42)"
end
has_number_gt(expression, float)
Tests whether expression
contains a number greater than min
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_gt("four hundred", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gt(\"four hundred\", \"foo\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_gt("the number is 40", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gt(\"the number is 40\", \"foo\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_gt("the number is 40", "40")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gt(\"the number is 40\", \"40\")"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_gt("the number is 42.0", "40")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gt(\"the number is 42.0\", \"40\")"
end
Example 5:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_gt("the number is 42", "40")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gt(\"the number is 42\", \"40\")"
end
Example 6:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_gt("the number is 42", 40.0)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gt(\"the number is 42\", 40.0)"
end
Example 7:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_gt("the number is 42", 40)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gt(\"the number is 42\", 40)"
end
has_number_gte(expression, float)
Tests whether expression
contains a number greater than or equal to min
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_gte("four hundred", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gte(\"four hundred\", \"foo\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_gte("the number is 40", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gte(\"the number is 40\", \"foo\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_gte("the number is 40", "45")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gte(\"the number is 40\", \"45\")"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_gte("the number is 42.0", "45")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gte(\"the number is 42.0\", \"45\")"
end
Example 5:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_gte("the number is 42", "42")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gte(\"the number is 42\", \"42\")"
end
Example 6:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_gte("the number is 42", 42.0)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gte(\"the number is 42\", 42.0)"
end
Example 7:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_gte("the number is 42", 42)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gte(\"the number is 42\", 42)"
end
has_number_lt(expression, float)
Tests whether expression
contains a number less than max
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_lt("four hundred", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lt(\"four hundred\", \"foo\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_lt("the number is 40", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lt(\"the number is 40\", \"foo\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_lt("the number is 40", "40")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lt(\"the number is 40\", \"40\")"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_lt("the number is 42.0", "40")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lt(\"the number is 42.0\", \"40\")"
end
Example 5:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_lt("the number is 42", "40")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lt(\"the number is 42\", \"40\")"
end
Example 6:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_lt("the number is 42", 44.0)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lt(\"the number is 42\", 44.0)"
end
Example 7:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_lt("the number is 42", 44)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lt(\"the number is 42\", 44)"
end
has_number_lte(expression, float)
Tests whether expression
contains a number less than or equal to max
Example 1:
When used as a Stack expression it returns a value of type Boolean: true
when used with the following context:
%{"response" => 3}
card MyCard do
my_var = has_number_lte("@response", 5)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lte(\"@response\", 5)"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_lte("four hundred", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lte(\"four hundred\", \"foo\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_lte("the number is 40", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lte(\"the number is 40\", \"foo\")"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_number_lte("the number is 42.0", "40")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lte(\"the number is 42.0\", \"40\")"
end
Example 5:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_lte("the number is 42", "42")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lte(\"the number is 42\", \"42\")"
end
Example 6:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_lte("the number is 42", 42.0)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lte(\"the number is 42\", 42.0)"
end
Example 7:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_number_lte("the number is 42", 42)
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lte(\"the number is 42\", 42)"
end
has_only_phrase(expression, phrase)
Tests whether the text contains only phrase
The phrase must be the only text in the text to match
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_only_phrase("The Quick Brown Fox", "quick brown")
# When used in a piece of text prefix it with an `@`
my_var = "@has_only_phrase(\"The Quick Brown Fox\", \"quick brown\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_only_phrase("", "")
# When used in a piece of text prefix it with an `@`
my_var = "@has_only_phrase(\"\", \"\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_only_phrase("Quick Brown", "quick brown")
# When used in a piece of text prefix it with an `@`
my_var = "@has_only_phrase(\"Quick Brown\", \"quick brown\")"
end
has_only_text(expression_one, expression_two)
Returns whether two text values are equal (case sensitive). In the case that they are, it will return the text as the match.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_only_text("foo", "FOO")
# When used in a piece of text prefix it with an `@`
my_var = "@has_only_text(\"foo\", \"FOO\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_only_text("", "")
# When used in a piece of text prefix it with an `@`
my_var = "@has_only_text(\"\", \"\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_only_text("foo", "foo")
# When used in a piece of text prefix it with an `@`
my_var = "@has_only_text(\"foo\", \"foo\")"
end
has_pattern(expression, pattern)
Tests whether expression
matches the regex pattern
Both text values are trimmed of surrounding whitespace and matching is case-insensitive.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_pattern("Sell cheese please", "buy (\w+)")
# When used in a piece of text prefix it with an `@`
my_var = "@has_pattern(\"Sell cheese please\", \"buy (\w+)\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_pattern("Buy cheese please", "buy (\w+)")
# When used in a piece of text prefix it with an `@`
my_var = "@has_pattern(\"Buy cheese please\", \"buy (\w+)\")"
end
has_phone(expression)
Tests whether expresssion
contains a phone number.
The optional country_code argument specifies the country to use for parsing.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_phone("my number is none of your business", "US")
# When used in a piece of text prefix it with an `@`
my_var = "@has_phone(\"my number is none of your business\", \"US\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_phone("my number is 206 779 9294 thanks", "US")
# When used in a piece of text prefix it with an `@`
my_var = "@has_phone(\"my number is 206 779 9294 thanks\", \"US\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_phone("my number is 2067799294 thanks", "US")
# When used in a piece of text prefix it with an `@`
my_var = "@has_phone(\"my number is 2067799294 thanks\", \"US\")"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_phone("my number is +12067799294 thanks")
# When used in a piece of text prefix it with an `@`
my_var = "@has_phone(\"my number is +12067799294 thanks\")"
end
has_phone(expression, country_code)
has_phrase(expression, phrase)
Tests whether phrase is contained in expression
The words in the test phrase must appear in the same order with no other words in between.
Example 1:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_phrase("the quick brown fox", "")
# When used in a piece of text prefix it with an `@`
my_var = "@has_phrase(\"the quick brown fox\", \"\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_phrase("the quick brown fox", "quick fox")
# When used in a piece of text prefix it with an `@`
my_var = "@has_phrase(\"the quick brown fox\", \"quick fox\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_phrase("the quick brown fox", "brown fox")
# When used in a piece of text prefix it with an `@`
my_var = "@has_phrase(\"the quick brown fox\", \"brown fox\")"
end
has_text(expression)
Tests whether there the expression
has any characters in it
Example 1:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_text(123)
# When used in a piece of text prefix it with an `@`
my_var = "@has_text(123)"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_text("
")
# When used in a piece of text prefix it with an `@`
my_var = "@has_text(\"
\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_text("")
# When used in a piece of text prefix it with an `@`
my_var = "@has_text(\"\")"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = has_text("quick brown")
# When used in a piece of text prefix it with an `@`
my_var = "@has_text(\"quick brown\")"
end
has_time(expression)
Tests whether expression
contains a time.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = has_time("there is no time here, just the number 25")
# When used in a piece of text prefix it with an `@`
my_var = "@has_time(\"there is no time here, just the number 25\")"
end
Example 2:
When used as a Stack expression it returns a complex Boolean type of default value:
true
with the following fields:
- match of type Time.
card MyCard do
my_var = has_time("the time is 10:30:45")
# When used in a piece of text prefix it with an `@`
my_var = "@has_time(\"the time is 10:30:45\")"
end
Example 3:
When used as a Stack expression it returns a complex Boolean type of default value:
true
with the following fields:
- match of type Time.
card MyCard do
my_var = has_time("the time is 10:00 pm")
# When used in a piece of text prefix it with an `@`
my_var = "@has_time(\"the time is 10:00 pm\")"
end
Example 4:
When used as a Stack expression it returns a complex Boolean type of default value:
true
with the following fields:
- match of type Time.
card MyCard do
my_var = has_time("the time is 10:30")
# When used in a piece of text prefix it with an `@`
my_var = "@has_time(\"the time is 10:30\")"
end
hf_connect(model_resource, token)
Connect a Huggingface model. The variable returned represents the connection to
the Huggingface model and should be used as the connection argument to the hf_infer
function.
Example 1: Connect to a model available on a custom Huggingface domain
When used as a Stack expression it returns a complex String type of default value:
"huggingface.co connection for \"/myhuggingface/model\""
with the following fields:
- type of type String
- token of type String
- url of type String.
card MyCard do
my_var = hf_connect("https://my-custom-domain.com/myhuggingface/model", "my-token")
# When used in a piece of text prefix it with an `@`
my_var = "@hf_connect(\"https://my-custom-domain.com/myhuggingface/model\", \"my-token\")"
end
Example 2: Connect to a model available on Huggingface.
Note that the the first argument is not a URL, but a reference to a Huggingface model in the format of "organisation-name/model-name" similar to how one might refer to a Github repository.
When used as a Stack expression it returns a complex String type of default value:
"huggingface.co connection for \"/models/myhuggingface/model\""
with the following fields:
- type of type String
- token of type String
- url of type String.
card MyCard do
my_var = hf_connect("myhuggingface/model", "my-token")
# When used in a piece of text prefix it with an `@`
my_var = "@hf_connect(\"myhuggingface/model\", \"my-token\")"
end
hf_infer(hf_connect, query)
Call the Huggingface inference API for the connection stored in the hf_connect
variable.
Example 1: Use the Huggingface inference API to submit an input query to a model specified in the connection variable. The value returned is the decoded JSON payload returned by the model hosted on Huggingface.
When used as a Stack expression it returns a value of type String: "nil is not a valid Huggingface connection."
.
card MyCard do
my_var = hf_infer(conn, "I am so happy today")
# When used in a piece of text prefix it with an `@`
my_var = "@hf_infer(conn, \"I am so happy today\")"
end
hour(date)
Returns only the hour of a datetime (0 to 23)
Example 1: Get the current hour
When used as a Stack expression it returns a value of type Integer: 16
.
card MyCard do
my_var = hour(now())
# When used in a piece of text prefix it with an `@`
my_var = "@hour(now())"
end
html_to_markdown(html)
Does a best effort at converting an HTML fragment into Markdown suitable for use in a WhatsApp conversation
Example 1:
When used as a Stack expression it returns a value of type String: "*hi*"
when used with the following context:
%{"html" => "<b>hi</b>"}
card MyCard do
my_var = html_to_markdown(html)
# When used in a piece of text prefix it with an `@`
my_var = "@html_to_markdown(html)"
end
if(condition, yes, no)
Returns one value if the condition evaluates to true
, and another value if it evaluates to false
Example 1:
When used as a Stack expression it returns a value of type String: "No"
.
card MyCard do
my_var = # Shorthand
if(false, do: "Yes", else: "No")
# When used in a piece of text prefix it with an `@`
my_var = "@if(false, \"Yes\", \"No\")"
end
Example 2:
When used as a Stack expression it returns a value of type String: "Yes"
.
card MyCard do
my_var = if true do
"Yes"
else
"No"
end
# When used in a piece of text prefix it with an `@`
my_var = "@if(true, \"Yes\", \"No\")"
end
isbool(var)
Returns true
if the argument is a boolean.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = isbool("false")
# When used in a piece of text prefix it with an `@`
my_var = "@isbool(\"false\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = isbool("true")
# When used in a piece of text prefix it with an `@`
my_var = "@isbool(\"true\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = isbool(0)
# When used in a piece of text prefix it with an `@`
my_var = "@isbool(0)"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = isbool(1)
# When used in a piece of text prefix it with an `@`
my_var = "@isbool(1)"
end
Example 5:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = isbool(false)
# When used in a piece of text prefix it with an `@`
my_var = "@isbool(false)"
end
Example 6:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = isbool(true)
# When used in a piece of text prefix it with an `@`
my_var = "@isbool(true)"
end
isnumber(var)
Returns true
if the argument is a number.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = isnumber("a")
# When used in a piece of text prefix it with an `@`
my_var = "@isnumber(\"a\")"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = isnumber("1.0")
# When used in a piece of text prefix it with an `@`
my_var = "@isnumber(\"1.0\")"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = isnumber(1.0)
# When used in a piece of text prefix it with an `@`
my_var = "@isnumber(1.0)"
end
Example 4:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = isnumber(1)
# When used in a piece of text prefix it with an `@`
my_var = "@isnumber(1)"
end
isstring(binary)
Returns true
if the argument is a string.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = isstring(1)
# When used in a piece of text prefix it with an `@`
my_var = "@isstring(1)"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = isstring(false)
# When used in a piece of text prefix it with an `@`
my_var = "@isstring(false)"
end
Example 3:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = isstring("hello")
# When used in a piece of text prefix it with an `@`
my_var = "@isstring(\"hello\")"
end
json(data)
Converts a data structure to JSON
Example 1:
When used as a Stack expression it returns a value of type String: "{\"foo\":\"bar\"}"
when used with the following context:
%{"data" => %{"foo" => "bar"}}
card MyCard do
my_var = json(data)
# When used in a piece of text prefix it with an `@`
my_var = "@json(data)"
end
left(binary, size)
Returns the first characters in a text string. This is Unicode safe.
Example 1:
When used as a Stack expression it returns a value of type String: "Умерла Мадлен Олбрай"
.
card MyCard do
my_var = left("Умерла Мадлен Олбрайт - первая женщина на посту главы Госдепа США", 20)
# When used in a piece of text prefix it with an `@`
my_var = "@left(\"Умерла Мадлен Олбрайт - первая женщина на посту главы Госдепа США\", 20)"
end
Example 2:
When used as a Stack expression it returns a value of type String: "foob"
.
card MyCard do
my_var = left("foobar", 4)
# When used in a piece of text prefix it with an `@`
my_var = "@left(\"foobar\", 4)"
end
len(binary)
Returns the number of characters in a text string
Example 1:
When used as a Stack expression it returns a value of type Integer: 3
.
card MyCard do
my_var = len("zoë")
# When used in a piece of text prefix it with an `@`
my_var = "@len(\"zoë\")"
end
Example 2:
When used as a Stack expression it returns a value of type Integer: 3
.
card MyCard do
my_var = len("foo")
# When used in a piece of text prefix it with an `@`
my_var = "@len(\"foo\")"
end
levenshtein_distance(first_phrase, second_phrase)
Calculate the Levenshtein edit distance.
Example 1:
When used as a Stack expression it returns a value of type Integer: 3
.
card MyCard do
my_var = levenshtein_distance("shalom", "salaam")
# When used in a piece of text prefix it with an `@`
my_var = "@levenshtein_distance(\"shalom\", \"salaam\")"
end
lower(binary)
Converts a text string to lowercase
Example 1:
When used as a Stack expression it returns a value of type String: "foo bar"
.
card MyCard do
my_var = lower("Foo Bar")
# When used in a piece of text prefix it with an `@`
my_var = "@lower(\"Foo Bar\")"
end
map(enumerable, mapper)
map over a list of items and apply the mapper function to every item, returning the result.
Example 1: Map over the range of numbers, multiple each by itself and return the result
When used as a Stack expression it returns a value of type List with values Integer, Integer, Integer: [
1,
4,
9
]
.
card MyCard do
my_var = map(1..3, &(&1 * &1))
# When used in a piece of text prefix it with an `@`
my_var = "@map(1..3, &(&1 * &1))"
end
Example 2: Map over the range of numbers, create a date in January for every number
When used as a Stack expression it returns a value of type List with values Date, Date, Date: [
"2022-01-01",
"2022-01-02",
"2022-01-03"
]
.
card MyCard do
my_var = map(1..3, &date(2022, 1, &1))
# When used in a piece of text prefix it with an `@`
my_var = "@map(1..3, &date(2022, 1, &1))"
end
max(argument1, argument2, argument3)
Returns the maximum value of all arguments
Example 1:
When used as a Stack expression it returns a value of type Integer: 3
.
card MyCard do
my_var = max(1, 2, 3)
# When used in a piece of text prefix it with an `@`
my_var = "@max(1, 2, 3)"
end
min(argument1, argument2, argument3)
Returns the minimum value of all arguments
Example 1:
When used as a Stack expression it returns a value of type Integer: 1
.
card MyCard do
my_var = min(1, 2, 3)
# When used in a piece of text prefix it with an `@`
my_var = "@min(1, 2, 3)"
end
minute(date)
Returns only the minute of a datetime (0 to 59)
Example 1: Get the current minute
When used as a Stack expression it returns a value of type Integer: 53
.
card MyCard do
my_var = minute(now())
# When used in a piece of text prefix it with an `@`
my_var = "@minute(now())"
end
month(date)
Returns only the month of a date (1 to 12)
Example 1: Get the current month
When used as a Stack expression it returns a value of type Integer: 8
.
card MyCard do
my_var = month(now())
# When used in a piece of text prefix it with an `@`
my_var = "@month(now())"
end
normalise_text(phrase)
Normalize text using Unicode NFKC (Normalisation Form Compatibility Composition) normalisation.
Accepts unicode multibyte characters and attempts to normalise them.
Example 1:
When used as a Stack expression it returns a value of type String: "abcABC"
when used with the following context:
%{"phrase" => "abcABC"}
card MyCard do
my_var = normalise_text(phrase)
# When used in a piece of text prefix it with an `@`
my_var = "@normalise_text(phrase)"
end
normalise_whitespace(phrase)
Normalise whitespace by replacing spans of whitespace with a single space
Example 1:
When used as a Stack expression it returns a value of type String: "hello world"
.
card MyCard do
my_var = normalise_whitespace("hello world")
# When used in a piece of text prefix it with an `@`
my_var = "@normalise_whitespace(\"hello world\")"
end
not(argument)
Returns false
if the argument supplied evaluates to truth-y
Example 1:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = not(false)
# When used in a piece of text prefix it with an `@`
my_var = "@not(false)"
end
now()
Returns the current date time as UTC
It is currently @NOW()
Example 1: return the current datetime and format it using datevalue
When used as a Stack expression it returns a complex String type of default value:
"2023-08-22"
with the following fields:
- date of type DateTime.
card MyCard do
my_var = datevalue(now(), "%Y-%m-%d")
# When used in a piece of text prefix it with an `@`
my_var = "@datevalue(now(), \"%Y-%m-%d\")"
end
Example 2: return the current timestamp as a DateTime value
When used as a Stack expression it returns a value of type DateTime: "2023-08-22T16:53:24.806552Z"
.
card MyCard do
my_var = now()
# When used in a piece of text prefix it with an `@`
my_var = "@now()"
end
or(argument1, argument2, argument3)
Returns true
if any argument is true
.
Returns the first truthy value found or otherwise false.
Accepts any amount of arguments for testing truthiness.
Example 1:
When used as a Stack expression it returns a value of type Boolean: false
.
card MyCard do
my_var = false or false
# When used in a piece of text prefix it with an `@`
my_var = "@or(false, false)"
end
Example 2:
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = true or true
# When used in a piece of text prefix it with an `@`
my_var = "@or(true, true)"
end
Example 3: Return the first value that is truthy
When used as a Stack expression it returns a value of type String: "foo"
.
card MyCard do
my_var = false or "foo"
# When used in a piece of text prefix it with an `@`
my_var = "@or(false, \"foo\")"
end
Example 4: Return true if any of the values are true
When used as a Stack expression it returns a value of type Boolean: true
.
card MyCard do
my_var = true or false
# When used in a piece of text prefix it with an `@`
my_var = "@or(true, false)"
end
parse_float(number)
parse_float(binary)
parse_json(data)
Parses a string as JSON
Example 1:
When used as a Stack expression it returns a value of type List with values Integer, Integer, Integer: [
1,
2,
3
]
.
card MyCard do
my_var = parse_json('[1,2,3]')
# When used in a piece of text prefix it with an `@`
my_var = "@parse_json('[1,2,3]')"
end
percent(float)
Formats a number as a percentage
Example 1:
When used as a Stack expression it returns a value of type String: "20%"
when used with the following context:
%{"d" => "0.2"}
card MyCard do
my_var = percent(d)
# When used in a piece of text prefix it with an `@`
my_var = "@percent(d)"
end
Example 2:
When used as a Stack expression it returns a value of type String: "20%"
.
card MyCard do
my_var = percent(0.2)
# When used in a piece of text prefix it with an `@`
my_var = "@percent(0.2)"
end
Example 3:
When used as a Stack expression it returns a value of type String: "20%"
.
card MyCard do
my_var = percent(2/10)
# When used in a piece of text prefix it with an `@`
my_var = "@percent(2/10)"
end
power(a, b)
Returns the result of a number raised to a power - equivalent to the ^ operator
Example 1:
When used as a Stack expression it returns a value of type Float: 8.0
.
card MyCard do
my_var = power(2, 3)
# When used in a piece of text prefix it with an `@`
my_var = "@power(2, 3)"
end
proper(binary)
Capitalizes the first letter of every word in a text string
Example 1:
When used as a Stack expression it returns a value of type String: "Foo Bar"
.
card MyCard do
my_var = proper("foo bar")
# When used in a piece of text prefix it with an `@`
my_var = "@proper(\"foo bar\")"
end
rand_between(min, max)
Generate a random number between min
and max
Example 1: Generate a number between 1 and 10
When used as a Stack expression it returns a value of type Integer: 6
.
card MyCard do
my_var = rand_between(1, 10)
# When used in a piece of text prefix it with an `@`
my_var = "@rand_between(1, 10)"
end
read_digits(binary)
Formats digits in text for reading in TTS
Example 1:
When used as a Stack expression it returns a value of type String: "plus two seven one"
.
card MyCard do
my_var = read_digits("+271")
# When used in a piece of text prefix it with an `@`
my_var = "@read_digits(\"+271\")"
end
reduce(enumerable, accumulator, reducer)
Reduces elements from a list by applying a function and collecting the results in an accumulator.
The first argument to the lambda function is the item from the list, the second argument is the accumulator.
Example 1:
When used as a Stack expression it returns a value of type Integer: 6
.
card MyCard do
my_var = reduce(1..3, 0, & &1 + &2)
# When used in a piece of text prefix it with an `@`
my_var = "@reduce(1..3, 0, & &1 + &2)"
end
regex_capture(binary, pattern)
Capture values out of a string using a regex.
Returns the list of captures in a list.
Returns nil
if there was nothing to match
Example 1:
When used as a Stack expression it returns a value of type Null: null
.
card MyCard do
my_var = regex_capture("testing", "foo(.+)")
# When used in a piece of text prefix it with an `@`
my_var = "@regex_capture(\"testing\", \"foo(.+)\")"
end
Example 2:
When used as a Stack expression it returns a value of type List with values String: [
"ing"
]
.
card MyCard do
my_var = regex_capture("testing", "test(.+)")
# When used in a piece of text prefix it with an `@`
my_var = "@regex_capture(\"testing\", \"test(.+)\")"
end
regex_named_capture(binary, pattern)
Captures named values out of a string using a regex.
In contrast to regex_capture()
this returns a map
where the keys are the names of the captures and the
values are the captured values.
Example 1:
When used as a Stack expression it returns a value of type Map: {}
.
card MyCard do
my_var = regex_named_capture("testing", "foo(?P<match>.+)")
# When used in a piece of text prefix it with an `@`
my_var = "@regex_named_capture(\"testing\", \"foo(?P<match>.+)\")"
end
Example 2:
When used as a Stack expression it returns a value of type Map: {
"match": "ing"
}
.
card MyCard do
my_var = regex_named_capture("testing", "test(?P<match>.+)")
# When used in a piece of text prefix it with an `@`
my_var = "@regex_named_capture(\"testing\", \"test(?P<match>.+)\")"
end
reject(enumerable, reject_fun)
Rejects elements from a list by returning a new list that contains only the
elements for which reject_fun
is truthy.
Example 1:
When used as a Stack expression it returns a value of type List with values String, String: [
"A",
"C"
]
.
card MyCard do
my_var = reject(["A", "B", "C", "B"], & &1 == "B")
# When used in a piece of text prefix it with an `@`
my_var = "@reject([\"A\", \"B\", \"C\", \"B\"], & &1 == \"B\")"
end
rem(integer1, integer2)
Return the division remainder of two integers.
Example 1:
When used as a Stack expression it returns a value of type Integer: 1
.
card MyCard do
my_var = rem(85, 3)
# When used in a piece of text prefix it with an `@`
my_var = "@rem(85, 3)"
end
Example 2:
When used as a Stack expression it returns a value of type Integer: 0
.
card MyCard do
my_var = rem(4, 2)
# When used in a piece of text prefix it with an `@`
my_var = "@rem(4, 2)"
end
remove_emojis(phrase)
Remove emojis from a string. Replaces it with a symbol rather than remove it completely for the following emojis: 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ #️⃣ *️⃣ ©️ ®️
Example 1:
When used as a Stack expression it returns a value of type String: "1 2 3 Turn loves you "
.
card MyCard do
my_var = remove_emojis("1️⃣ 2️⃣ 3️⃣ Turn loves you ❤️")
# When used in a piece of text prefix it with an `@`
my_var = "@remove_emojis(\"1️⃣ 2️⃣ 3️⃣ Turn loves you ❤️\")"
end
remove_first_word(binary)
Removes the first word from the given text. The remaining text will be unchanged
Example 1:
When used as a Stack expression it returns a value of type String: "bar"
.
card MyCard do
my_var = remove_first_word("foo-bar", "-")
# When used in a piece of text prefix it with an `@`
my_var = "@remove_first_word(\"foo-bar\", \"-\")"
end
Example 2:
When used as a Stack expression it returns a value of type String: "bar"
.
card MyCard do
my_var = remove_first_word("foo bar")
# When used in a piece of text prefix it with an `@`
my_var = "@remove_first_word(\"foo bar\")"
end
remove_first_word(binary, separator)
remove_numbers(phrase)
Remove numbers
Example 1:
When used as a Stack expression it returns a value of type String: "counting down "
.
card MyCard do
my_var = remove_numbers("counting down 3 2 1")
# When used in a piece of text prefix it with an `@`
my_var = "@remove_numbers(\"counting down 3 2 1\")"
end
remove_punc(phrase)
Remove punctuation without substitution
Example 1:
When used as a Stack expression it returns a value of type String: "hello world"
.
card MyCard do
my_var = remove_punc("hello? world!")
# When used in a piece of text prefix it with an `@`
my_var = "@remove_punc(\"hello? world!\")"
end
replace_punc(phrase)
Replace punctuation marks with spaces
Example 1:
When used as a Stack expression it returns a value of type String: "hello world "
.
card MyCard do
my_var = replace_punc("hello? world!")
# When used in a piece of text prefix it with an `@`
my_var = "@replace_punc(\"hello? world!\")"
end
rept(value, amount)
Repeats text a given number of times
Example 1:
When used as a Stack expression it returns a value of type String: "**********"
.
card MyCard do
my_var = rept("*", 10)
# When used in a piece of text prefix it with an `@`
my_var = "@rept(\"*\", 10)"
end
right(binary, size)
Returns the last characters in a text string. This is Unicode safe.
Example 1:
When used as a Stack expression it returns a value of type String: "ту главы Госдепа США"
.
card MyCard do
my_var = right("Умерла Мадлен Олбрайт - первая женщина на посту главы Госдепа США", 20)
# When used in a piece of text prefix it with an `@`
my_var = "@right(\"Умерла Мадлен Олбрайт - первая женщина на посту главы Госдепа США\", 20)"
end
Example 2:
When used as a Stack expression it returns a value of type String: "ing"
.
card MyCard do
my_var = right("testing", 3)
# When used in a piece of text prefix it with an `@`
my_var = "@right(\"testing\", 3)"
end
scrub_message_by_id(id)
Permanently scrubs a message by its given ID.
Example 1:
When used as a Stack expression it returns a complex Boolean type of default value:
true
with the following fields:
- type of type String.
card MyCard do
my_var = scrub_message_by_id(event.message.id)
# When used in a piece of text prefix it with an `@`
my_var = "@scrub_message_by_id(event.message.id)"
end
scrub_session_messages()
Permanently scrubs all the processed messages during the current session.
Example 1:
When used as a Stack expression it returns a complex Boolean type of default value:
true
with the following fields:
- type of type String.
card MyCard do
my_var = scrub_session_messages()
# When used in a piece of text prefix it with an `@`
my_var = "@scrub_session_messages()"
end
second(date)
Returns only the second of a datetime (0 to 59)
Example 1:
When used as a Stack expression it returns a value of type Integer: 6
when used with the following context:
%{"now" => ~U[2023-08-16 21:14:06.737711Z]}
card MyCard do
my_var = second(now)
# When used in a piece of text prefix it with an `@`
my_var = "@second(now)"
end
sort_by(enumerable, sorter_fun)
Sorts a list of values using the result of the sorter function
Example 1:
When used as a Stack expression it returns a value of type List with values String, String, String: [
"a",
"b",
"c"
]
.
card MyCard do
my_var = sort_by(["a", "b", "c"], &rand_between(1, 5))
# When used in a piece of text prefix it with an `@`
my_var = "@sort_by([\"a\", \"b\", \"c\"], &rand_between(1, 5))"
end
split(binary)
Split a string into an array using the pattern as separator. Defaults to split the string using a space.
Example 1:
When used as a Stack expression it returns a value of type List with values String, String, String: [
"t",
"sting som",
"thing"
]
.
card MyCard do
my_var = split("testing something", "e")
# When used in a piece of text prefix it with an `@`
my_var = "@split(\"testing something\", \"e\")"
end
Example 2:
When used as a Stack expression it returns a value of type List with values String, String: [
"testing",
"something"
]
.
card MyCard do
my_var = split("testing something")
# When used in a piece of text prefix it with an `@`
my_var = "@split(\"testing something\")"
end
split(binary, pattern)
substitute(subject, pattern, replacement)
Substitutes new_text for old_text in a text string. If instance_num is given, then only that instance will be substituted
Example 1:
When used as a Stack expression it returns a value of type String: "I can do"
.
card MyCard do
my_var = substitute("I can't", "can't", "can do")
# When used in a piece of text prefix it with an `@`
my_var = "@substitute(\"I can't\", \"can't\", \"can do\")"
end
sum(argument1, argument2, argument3)
Returns the sum of all arguments, equivalent to the + operator
You have @SUM(contact.reports, contact.forms) reports and forms
Example 1:
When used as a Stack expression it returns a value of type Integer: 6
.
card MyCard do
my_var = sum(1, 2, 3)
# When used in a piece of text prefix it with an `@`
my_var = "@sum(1, 2, 3)"
end
time(hours, minutes, seconds)
Defines a time value which can be used for time arithmetic
Example 1:
When used as a Stack expression it returns a value of type Time: "12:13:14"
.
card MyCard do
my_var = time(12, 13, 14)
# When used in a piece of text prefix it with an `@`
my_var = "@time(12, 13, 14)"
end
timevalue(expression)
Converts time stored in text to an actual time
Example 1:
When used as a Stack expression it returns a value of type Time: "02:30:55"
.
card MyCard do
my_var = timevalue("2:30:55")
# When used in a piece of text prefix it with an `@`
my_var = "@timevalue(\"2:30:55\")"
end
Example 2:
When used as a Stack expression it returns a value of type Time: "02:30:00"
.
card MyCard do
my_var = timevalue("2:30")
# When used in a piece of text prefix it with an `@`
my_var = "@timevalue(\"2:30\")"
end
today()
Returns the current date
Example 1:
When used as a Stack expression it returns a value of type Date: "2023-08-22"
.
card MyCard do
my_var = today()
# When used in a piece of text prefix it with an `@`
my_var = "@today()"
end
unichar(code)
Returns the unicode character specified by a number
Example 1:
When used as a Stack expression it returns a value of type String: "é"
.
card MyCard do
my_var = unichar(233)
# When used in a piece of text prefix it with an `@`
my_var = "@unichar(233)"
end
Example 2:
When used as a Stack expression it returns a value of type String: "A"
.
card MyCard do
my_var = unichar(65)
# When used in a piece of text prefix it with an `@`
my_var = "@unichar(65)"
end
unicode(letter)
Returns a numeric code for the first character in a text string
Example 1:
When used as a Stack expression it returns a value of type Integer: 233
.
card MyCard do
my_var = unicode("é")
# When used in a piece of text prefix it with an `@`
my_var = "@unicode(\"é\")"
end
Example 2:
When used as a Stack expression it returns a value of type Integer: 65
.
card MyCard do
my_var = unicode("A")
# When used in a piece of text prefix it with an `@`
my_var = "@unicode(\"A\")"
end
uniq(enumerable)
Removes duplicate values from a list.
Example 1:
When used as a Stack expression it returns a value of type List with values String, String, String: [
"A",
"B",
"C"
]
.
card MyCard do
my_var = uniq(["A", "B", "C", "B"])
# When used in a piece of text prefix it with an `@`
my_var = "@uniq([\"A\", \"B\", \"C\", \"B\"])"
end
upper(binary)
Converts a text string to uppercase
Example 1:
When used as a Stack expression it returns a value of type String: "FOO"
.
card MyCard do
my_var = upper("foo")
# When used in a piece of text prefix it with an `@`
my_var = "@upper(\"foo\")"
end
weekday(date)
Returns the day of the week of a date (1 for Sunday to 7 for Saturday)
Example 1:
When used as a Stack expression it returns a value of type Integer: 3
when used with the following context:
%{"today" => ~D[2022-11-01]}
card MyCard do
my_var = weekday(today)
# When used in a piece of text prefix it with an `@`
my_var = "@weekday(today)"
end
Example 2:
When used as a Stack expression it returns a value of type Integer: 1
when used with the following context:
%{"today" => ~D[2022-11-06]}
card MyCard do
my_var = weekday(today)
# When used in a piece of text prefix it with an `@`
my_var = "@weekday(today)"
end
with_index(enumerable)
Wraps each item of the list in a new list with the item itself and its index in the original list.
Example 1:
When used as a Stack expression it returns a value of type List with values List with values String, Integer, List with values String, Integer, List with values String, Integer: [
[
"A",
0
],
[
"B",
1
],
[
"C",
2
]
]
.
card MyCard do
my_var = with_index(["A", "B", "C"])
# When used in a piece of text prefix it with an `@`
my_var = "@with_index([\"A\", \"B\", \"C\"])"
end
word(binary, n)
Extracts the nth word from the given text string. If stop is a negative number,
then it is treated as count backwards from the end of the text. If by_spaces is
specified and is true
then the function splits the text into words only by spaces.
Otherwise the text is split by punctuation characters as well
Example 1:
When used as a Stack expression it returns a value of type String: "boy"
.
card MyCard do
my_var = word("hello cow-boy", -1)
# When used in a piece of text prefix it with an `@`
my_var = "@word(\"hello cow-boy\", -1)"
end
Example 2:
When used as a Stack expression it returns a value of type String: "cow-boy"
.
card MyCard do
my_var = word("hello cow-boy", 2, true)
# When used in a piece of text prefix it with an `@`
my_var = "@word(\"hello cow-boy\", 2, true)"
end
Example 3:
When used as a Stack expression it returns a value of type String: "cow"
.
card MyCard do
my_var = word("hello cow-boy", 2)
# When used in a piece of text prefix it with an `@`
my_var = "@word(\"hello cow-boy\", 2)"
end
word(binary, n, by_spaces)
word_count(binary)
Returns the number of words in the given text string. If by_spaces is specified and is true
then the function splits the text into words only by spaces. Otherwise the text is split by punctuation characters as well
> You entered @word_count("one two three") words
You entered 3 words
Example 1:
When used as a Stack expression it returns a value of type Integer: 2
.
card MyCard do
my_var = word_count("hello cow-boy", true)
# When used in a piece of text prefix it with an `@`
my_var = "@word_count(\"hello cow-boy\", true)"
end
Example 2:
When used as a Stack expression it returns a value of type Integer: 3
.
card MyCard do
my_var = word_count("hello cow-boy")
# When used in a piece of text prefix it with an `@`
my_var = "@word_count(\"hello cow-boy\")"
end
word_count(binary, by_spaces)
word_slice(binary, start)
Extracts a substring of the words beginning at start, and up to but not-including stop.
If stop is omitted then the substring will be all words from start until the end of the text.
If stop is a negative number, then it is treated as count backwards from the end of the text.
If by_spaces is specified and is true
then the function splits the text into words only by spaces.
Otherwise the text is split by punctuation characters as well
Example 1:
When used as a Stack expression it returns a value of type String: "fun"
.
card MyCard do
my_var = word_slice("FLOIP expressions are fun", -1)
# When used in a piece of text prefix it with an `@`
my_var = "@word_slice(\"FLOIP expressions are fun\", -1)"
end
Example 2:
When used as a Stack expression it returns a value of type String: "FLOIP expressions"
.
card MyCard do
my_var = word_slice("FLOIP expressions are fun", 1, -2)
# When used in a piece of text prefix it with an `@`
my_var = "@word_slice(\"FLOIP expressions are fun\", 1, -2)"
end
Example 3:
When used as a Stack expression it returns a value of type String: "expressions are fun"
.
card MyCard do
my_var = word_slice("FLOIP expressions are fun", 2)
# When used in a piece of text prefix it with an `@`
my_var = "@word_slice(\"FLOIP expressions are fun\", 2)"
end
Example 4:
When used as a Stack expression it returns a value of type String: "expressions are"
.
card MyCard do
my_var = word_slice("FLOIP expressions are fun", 2, 4)
# When used in a piece of text prefix it with an `@`
my_var = "@word_slice(\"FLOIP expressions are fun\", 2, 4)"
end
word_slice(binary, start, stop)
word_slice(binary, start, stop, by_spaces)
year(date)
Returns only the year of a date
Example 1:
When used as a Stack expression it returns a value of type Integer: 2023
when used with the following context:
%{"now" => ~U[2023-08-16 21:14:06.784907Z]}
card MyCard do
my_var = year(now)
# When used in a piece of text prefix it with an `@`
my_var = "@year(now)"
end