Skip to main content

Expressions Reference

abs(number)

Returns the absolute value of a number

Example 1:

When used as a Journey expression it returns a value of type Float: 0.5.

card MyCard do
my_var = abs(-0.5)
# When used in a piece of text prefix it with an `@`
my_var = "@abs(-0.5)"
end

Example 2:

When used as a Journey 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 Journey 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 Journey 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

append(list, payload)

Appends an item or a list of items to a given list.

Example 1:

When used as a Journey expression it returns a value of type List with values String, String, String, String:

[
"A",
"B",
"C",
"B"
]
card MyCard do
my_var = append(["A", "B"], ["C", "B"])
# When used in a piece of text prefix it with an `@`
my_var = "@append([\"A\", \"B\"], [\"C\", \"B\"])"
end

Example 2:

When used as a Journey expression it returns a value of type List with values String, String, String:

[
"A",
"B",
"C"
]
card MyCard do
my_var = append(["A", "B"], "C")
# When used in a piece of text prefix it with an `@`
my_var = "@append([\"A\", \"B\"], \"C\")"
end

attachment_url(media_id, ttl)

Return a time-limited URL that gives access to the media referenced by the given id.

Example 1: Return a URL for an attachment received with a limited TTL.

The second parameter is the amount of minutes the URL will be valid for. If not supplied it defaults to 15.

When used as a Journey expression it returns a value of type String: "https://example.org/attachment-url".

card MyCard do
my_var = attachment_url(event.message.image.id, 10)
# When used in a piece of text prefix it with an `@`
my_var = "@attachment_url(event.message.image.id, 10)"
end

attachment_url(media_id)

Generate a URL for the given media ID that is valid for 15 minutes.

Example 1: Return a URL for an attachment that is valid for 15 minutes.

When used as a Journey expression it returns a value of type String: "https://example.org/attachment-url".

card MyCard do
my_var = attachment_url(event.message.image.id)
# When used in a piece of text prefix it with an `@`
my_var = "@attachment_url(event.message.image.id)"
end

base64_decode(thing)

Base64 decode an expression

Example 1:

When used as a Journey expression it returns a value of type String: "hello world".

card MyCard do
my_var = base64_decode("aGVsbG8gd29ybGQ=")
# When used in a piece of text prefix it with an `@`
my_var = "@base64_decode(\"aGVsbG8gd29ybGQ=\")"
end

base64_encode(thing)

Base64 encode an expression

Example 1:

When used as a Journey expression it returns a value of type String: "aGVsbG8gd29ybGQ=".

card MyCard do
my_var = base64_encode("hello world")
# When used in a piece of text prefix it with an `@`
my_var = "@base64_encode(\"hello world\")"
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 Journey 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

chunk_every(enumerable, count)

Chunk a list into a list of smaller lists.

This is useful in cases where one has a large list but want to process them in smaller chunks.

Example 1: Split a large set of sentences into a smaller set of sentences.

When used as a Journey expression it returns a value of type List with values List with values String, String, List with values String, String, List with values String:

[
[
"the first sentence",
"the second sentence"
],
[
"the third sentence",
"the fourth sentence"
],
[
"the fifth sentence"
]
]

when used with the following context:

%{"sentences" => ["the first sentence", "the second sentence", "the third sentence", "the fourth sentence", "the fifth sentence"]}
card MyCard do
my_var = chunk_every(sentences, 2)
# When used in a piece of text prefix it with an `@`
my_var = "@chunk_every(sentences, 2)"
end

clean(binary)

Removes all non-printable characters from a text string

Example 1:

When used as a Journey expression it returns a value of type String: "".

card MyCard do
my_var = clean(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@clean(nil)"
end

Example 2:

When used as a Journey 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 Journey expression it returns a value of type Null: null.

card MyCard do
my_var = code(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@code(nil)"
end

Example 2:

When used as a Journey 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 Journey 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 Journey expression it returns a value of type Integer: 0 when used with the following context:

%{"nil_value" => nil}
card MyCard do
my_var = count(nil_value)
# When used in a piece of text prefix it with an `@`
my_var = "@count(nil_value)"
end

Example 2:

When used as a Journey 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 3:

When used as a Journey 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 4:

When used as a Journey 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 Journey 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 Journey 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: Invalid date inputs

When used as a Journey expression it returns a value of type Map:

{
"__type__": "expression/v1error",
"error": true,
"message": "Invalid date"
}

when used with the following context:

%{}
card MyCard do
my_var = datetime_add("_..[0]._", 0, "h")
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_add(\"_..[0]._\", 0, \"h\")"
end

Example 2: Negative offsets

When used as a Journey 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 3: Leap year handling outside of a leap year.

When used as a Journey 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 4: Leap year handling in a leap year.

When used as a Journey 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 5: Calculates a new datetime based on the offset and unit provided.

When used as a Journey 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_from_unix(unix, unit)

Parses a UNIX time and returns a DateTime

Example 1:

When used as a Journey expression it returns a value of type DateTime: "2023-12-06T23:00:00Z" when used with the following context:

%{}
card MyCard do
my_var = datetime_from_unix("1701903600", "second")
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_from_unix(\"1701903600\", \"second\")"
end

Example 2:

When used as a Journey expression it returns a value of type DateTime: "2023-12-06T23:00:00.000Z" when used with the following context:

%{}
card MyCard do
my_var = datetime_from_unix(1701903600000, "millisecond")
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_from_unix(1701903600000, \"millisecond\")"
end

Example 3:

When used as a Journey expression it returns a value of type DateTime: "2023-12-06T23:00:00.000Z" when used with the following context:

%{}
card MyCard do
my_var = datetime_from_unix("1701903600000", "millisecond")
# When used in a piece of text prefix it with an `@`
my_var = "@datetime_from_unix(\"1701903600000\", \"millisecond\")"
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 Journey 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 Journey 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 Journey expression it returns a value of type DateTime: "2024-10-12T13: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 Journey 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 Journey 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 Journey expression it returns a complex String type of default value:

"2022-01-01 00:00:00"

with the following fields:

  • date of type Date
  • datetime of type DateTime.
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 Journey expression it returns a value of type Integer: 8.

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 Journey 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

delete(map, key)

Deletes an element from a map by the given key.

Example 1:

When used as a Journey expression it returns a value of type Map:

{
"age": 32
}

when used with the following context:

%{"patient" => %{"age" => 32, "gender" => "?"}}
card MyCard do
my_var = delete(patient, "gender")
# When used in a piece of text prefix it with an `@`
my_var = "@delete(patient, \"gender\")"
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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type String: "".

card MyCard do
my_var = first_word(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@first_word(nil)"
end

Example 2:

When used as a Journey 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 Journey expression it returns a value of type String: "0.09".

card MyCard do
my_var = fixed(0.0909, 2)
# When used in a piece of text prefix it with an `@`
my_var = "@fixed(0.0909, 2)"
end

Example 2:

When used as a Journey 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 3:

When used as a Journey 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 4:

When used as a Journey expression it returns a value of type String: "4000.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 5:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type String: "{\"chat\":\"current chat...\",\"contact\":\"current contact...\",\"number\":\"current number...\",\"results\":[{\"question\":\"the question reference...\",\"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 Journey 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 Journey 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 Journey 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_members(list, items)

Return true if a list contains all the provided items

Example 1: Check whether the given list contains all the provided items

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_all_members(["A", "B", "C"], ["C", "B"])
# When used in a piece of text prefix it with an `@`
my_var = "@has_all_members([\"A\", \"B\", \"C\"], [\"C\", \"B\"])"
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 Journey expression it returns a value of type Boolean: false.

card MyCard do
my_var = has_all_words(nil, "red fox")
# When used in a piece of text prefix it with an `@`
my_var = "@has_all_words(nil, \"red fox\")"
end

Example 2:

When used as a Journey 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 3:

When used as a Journey 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_beginning(text, prefixes)

Checks if the given text starts with any of the provided prefixes. The function performs a case-insensitive match.

Example 1:

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_any_beginning("كيف حالك؟", ["كيف حالك", "hey how are you"])
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_beginning(\"كيف حالك؟\", [\"كيف حالك\", \"hey how are you\"])"
end

Example 2:

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_any_beginning("HEY HOW ARE YOU?", ["hello", "hey how are you"])
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_beginning(\"HEY HOW ARE YOU?\", [\"hello\", \"hey how are you\"])"
end

has_any_end(text, end_texts)

Example 1: Check whether the given text ends with any of the provided strings. The function performs a case-insensitive match.

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_any_end("I would like to book a vaccine", ["appointment", "visit", "vaccine"])
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_end(\"I would like to book a vaccine\", [\"appointment\", \"visit\", \"vaccine\"])"
end

has_any_exact_phrase(text, phrases)

Check whether the given text exactly matches any of the provided phrases. The function performs a case-insensitive exact match.

Example 1:

When used as a Journey expression it returns a value of type Boolean: false.

card MyCard do
my_var = has_any_exact_phrase("كيف حالك؟", ["كيف حالك", "hey how are you"])
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_exact_phrase(\"كيف حالك؟\", [\"كيف حالك\", \"hey how are you\"])"
end

Example 2:

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_any_exact_phrase("HEY HOW ARE YOU?", ["hello", "hey how are you?"])
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_exact_phrase(\"HEY HOW ARE YOU?\", [\"hello\", \"hey how are you?\"])"
end

has_any_member(list, items)

Return true if a list contains any of the provided items

Example 1: Check whether the given list contains any of the provided items

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_any_member(["A", "B", "C"], ["Z", "C"])
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_member([\"A\", \"B\", \"C\"], [\"Z\", \"C\"])"
end

has_any_phrase(text, phrases)

Check whether the given text contains any of the provided strings. The function performs a case-insensitive exact match. The second argument expects either a list of strings or a single string with comma-separated phrases.

Example 1:

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_any_phrase("hey how are you?", "hello, bye bye, how are you")
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_phrase(\"hey how are you?\", \"hello, bye bye, how are you\")"
end

Example 2:

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_any_phrase("مرحباً كيف حالك؟", ["كيف حالك", "how are you"])
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_phrase(\"مرحباً كيف حالك؟\", [\"كيف حالك\", \"how are you\"])"
end

Example 3:

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_any_phrase("hey how are you?", ["hello", "bye bye", "how are you"])
# When used in a piece of text prefix it with an `@`
my_var = "@has_any_phrase(\"hey how are you?\", [\"hello\", \"bye bye\", \"how are you\"])"
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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • date of type Null
  • datetime of type Null
  • match of type Null when used with the following context:
%{"var" => 1}
card MyCard do
my_var = has_date(var)
# When used in a piece of text prefix it with an `@`
my_var = "@has_date(var)"
end

Example 2:

When used as a Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • date of type Null
  • datetime of type Null
  • match of type Null.
card MyCard do
my_var = has_date(1)
# When used in a piece of text prefix it with an `@`
my_var = "@has_date(1)"
end

Example 3:

When used as a Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • date of type Null
  • datetime of type Null
  • match of type Null.
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 4:

When used as a Journey expression it returns a value of type DateTime: "2017-01-15T05:50:00Z".

card MyCard do
my_var = has_date("the date is 15/01/2017 05:50").datetime
# When used in a piece of text prefix it with an `@`
my_var = "@has_date(\"the date is 15/01/2017 05:50\").datetime"
end

Example 5:

When used as a Journey expression it returns a value of type Date: "2017-01-15".

card MyCard do
my_var = has_date("the date is 15/01/2017").date
# When used in a piece of text prefix it with an `@`
my_var = "@has_date(\"the date is 15/01/2017\").date"
end

Example 6:

When used as a Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • date of type Date
  • datetime of type DateTime
  • match of type DateTime.
card MyCard do
my_var = has_date("the date is 15/01/2017 05:50")
# When used in a piece of text prefix it with an `@`
my_var = "@has_date(\"the date is 15/01/2017 05:50\")"
end

has_date_eq(expression, date_string)

Tests whether expression is a date equal to date_string

Example 1:

When used as a Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • error of type Map
  • match of type Null
  • test of type Date.
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 Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • match of type Date
  • test of type Date.
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 Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • match of type Date
  • test of type Date.
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 Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • match of type Date
  • test of type Date.
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 Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • match of type Date
  • test of type Date.
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 Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • match of type Date
  • test of type Date.
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 Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • email of type Null.
card MyCard do
my_var = has_email(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@has_email(nil)"
end

Example 2:

When used as a Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • email of type Null.
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 3:

When used as a Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • email of type String.
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_end(text, end_text)

Example 1: Check whether the given text ends with the provided string. The function performs a case-insensitive match.

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_end("I would like to book a vaccine", "vaccine")
# When used in a piece of text prefix it with an `@`
my_var = "@has_end(\"I would like to book a vaccine\", \"vaccine\")"
end

has_group(groups, uuid)

Returns whether the contact is part of group with the passed in UUID

Example 1:

When used as a Journey 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 Journey 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 Journey 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 Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • number of type Float.
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 Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • number of type Float.
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 Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • number of type Float.
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 Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • number of type Float.
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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_number_eq("the number is 0.5", "0.5")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_eq(\"the number is 0.5\", \"0.5\")"
end

Example 6:

When used as a Journey 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 7:

When used as a Journey 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 8:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_number_gt("the number is 0.6", "0.5")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gt(\"the number is 0.6\", \"0.5\")"
end

Example 6:

When used as a Journey 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 7:

When used as a Journey 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 8:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_number_gte("the number is 0.5", "0.5")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_gte(\"the number is 0.5\", \"0.5\")"
end

Example 6:

When used as a Journey 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 7:

When used as a Journey 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 8:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Boolean: false.

card MyCard do
my_var = has_number_lt("the number is 0.6", "0.5")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lt(\"the number is 0.6\", \"0.5\")"
end

Example 6:

When used as a Journey 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 7:

When used as a Journey 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 8:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = has_number_lte("the number is 0.5", "0.5")
# When used in a piece of text prefix it with an `@`
my_var = "@has_number_lte(\"the number is 0.5\", \"0.5\")"
end

Example 6:

When used as a Journey 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 7:

When used as a Journey 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 8:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Boolean: false.

card MyCard do
my_var = has_pattern(nil, "buy (\w+)")
# When used in a piece of text prefix it with an `@`
my_var = "@has_pattern(nil, \"buy (\w+)\")"
end

Example 2:

When used as a Journey 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 3:

When used as a Journey 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 Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • phonenumber of type Null.
card MyCard do
my_var = has_phone(nil, "US")
# When used in a piece of text prefix it with an `@`
my_var = "@has_phone(nil, \"US\")"
end

Example 2:

When used as a Journey expression it returns a complex Boolean type of default value:

false

with the following fields:

  • phonenumber of type Null.
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 3:

When used as a Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • phonenumber of type String.
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 4:

When used as a Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • phonenumber of type String.
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 5:

When used as a Journey expression it returns a complex Boolean type of default value:

true

with the following fields:

  • phonenumber of type String.
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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Boolean: false.

card MyCard do
my_var = has_text(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@has_text(nil)"
end

Example 2:

When used as a Journey 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 3:

When used as a Journey 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 Journey 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 5:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Integer: 15.

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 Journey 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 Journey 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 Journey 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

is_error(value)

Checks whether value is an error

Example 1:

When used as a Journey expression it returns a value of type Boolean: false when used with the following context:

%{}
card MyCard do
my_var = is_error("not an error")
# When used in a piece of text prefix it with an `@`
my_var = "@is_error(\"not an error\")"
end

Example 2:

When used as a Journey expression it returns a value of type Boolean: true when used with the following context:

%{"error" => %{"__type__" => "expression/v1error", "error" => true, "message" => "the error"}}
card MyCard do
my_var = is_error(error)
# When used in a piece of text prefix it with an `@`
my_var = "@is_error(error)"
end

is_nil_or_empty(arg)

Returns true if the argument is nil or an empty string

Example 1: Check whether the given argument is nil or an empty string

When used as a Journey expression it returns a value of type Boolean: true.

card MyCard do
my_var = is_nil_or_empty(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@is_nil_or_empty(nil)"
end

isbool(var)

Returns true if the argument is a boolean.

Example 1:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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.

It will return nil if the given string is nil

Example 1:

When used as a Journey expression it returns a value of type Null: null.

card MyCard do
my_var = left(nil, 4)
# When used in a piece of text prefix it with an `@`
my_var = "@left(nil, 4)"
end

Example 2:

When used as a Journey 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 3:

When used as a Journey 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, returns 0 if the string is null or empty

Example 1:

When used as a Journey expression it returns a value of type Integer: 0.

card MyCard do
my_var = len(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@len(nil)"
end

Example 2:

When used as a Journey 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 3:

When used as a Journey 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 Journey 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 Journey expression it returns a value of type Null: null.

card MyCard do
my_var = lower(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@lower(nil)"
end

Example 2:

When used as a Journey 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 Journey 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 Journey 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 Journey 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

mid(text, start_num, num_chars)

MID extracts part of a string, starting at a specified position and for a specified length.

It correctly handles Unicode characters. For example, taking the first three characters from "héllo" returns "hél".

If the starting position is beyond the string length, it returns an empty string.

Implementation based on https://support.microsoft.com/en-us/office/mid-function-2eba57be-0c05-4bdc-bf81-5ecf4421eb8a

Example 1:

When used as a Journey expression it returns a value of type String: "".

card MyCard do
my_var = MID("Fluid Flow", 20, 5)
# When used in a piece of text prefix it with an `@`
my_var = "@MID(\"Fluid Flow\", 20, 5)"
end

Example 2:

When used as a Journey expression it returns a value of type String: "Flow".

card MyCard do
my_var = MID("Fluid Flow", 7, 20)
# When used in a piece of text prefix it with an `@`
my_var = "@MID(\"Fluid Flow\", 7, 20)"
end

Example 3: MID returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.

When used as a Journey expression it returns a value of type String: "Fluid".

card MyCard do
my_var = MID("Fluid", 1, 5)
# When used in a piece of text prefix it with an `@`
my_var = "@MID(\"Fluid\", 1, 5)"
end

min(argument1, argument2, argument3)

Returns the minimum value of all arguments

Example 1:

When used as a Journey 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 Journey expression it returns a value of type Integer: 0.

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 Journey expression it returns a value of type Integer: 10.

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 Journey 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 Journey 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 Journey 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 Journey expression it returns a complex String type of default value:

"2024-10-08"

with the following fields:

  • date of type Date
  • datetime 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 Journey expression it returns a value of type DateTime: "2024-10-08T15:00:17.206684Z".

card MyCard do
my_var = now()
# When used in a piece of text prefix it with an `@`
my_var = "@now()"
end

openai_add_function(connection, name, description, parameters)

Add a function definition to the OpenAI context for the given role.

Example 1: Add a function called make_booking to the OpenAI context

When used as a Journey expression it returns a value of type Map:

{
"__type__": "openai/v1",
"functions": [
{
"function": {
"description": "Make an appointment booking",
"name": "make_booking",
"parameters": {
"properties": {},
"type": "object"
}
},
"type": "function"
}
]
}

when used with the following context:

%{"ai" => %{"__type__" => "openai/v1", "functions" => []}}
card MyCard do
my_var = openai_add_function(ai, "make_booking", "Make an appointment booking", parse_json('{
"type": "object",
"properties": {}
}'))

# When used in a piece of text prefix it with an `@`
my_var = "@openai_add_function(ai, \"make_booking\", \"Make an appointment booking\", parse_json('{
\"type\": \"object\",
\"properties\": {}
}'))
"
end

openai_add_image(connection, role, prompt, image_url)

Add an image to the OpenAI context for the given role, this requires one to setup a connection with a vision capable model.

By default this sets a maximum of 300 tokens.

Example 1: Add an image to the OpenAI context for use with the Vision API.

ai = openai_add_image(ai, "user", question, image_url)
completion = openai_chat_completion(ai)
text("@completion.response")

When used as a Journey expression it returns a value of type Map:

{
"__type__": "openai/v1",
"max_tokens": 300,
"messages": [
{
"content": [
{
"text": "Describe this image",
"type": "text"
},
{
"image_url": {
"url": {
"__value__": null,
"error": true,
"message": "Unable to generate URL for given ID"
}
},
"type": "image_url"
}
],
"role": "user"
}
]
}

when used with the following context:

%{"ai" => %{"__type__" => "openai/v1", "messages" => []}}
card MyCard do
my_var = openai_add_image(ai, "user", "Describe this image", attachment_url(event.message.image.id))

# When used in a piece of text prefix it with an `@`
my_var = "@openai_add_image(ai, \"user\", \"Describe this image\", attachment_url(event.message.image.id))
"
end

openai_add_image(connection, role, prompt, image_url, max_tokens)

Add an image to the OpenAI context for the given role, this requires one to setup a connection with a vision capable model.

This allows one to specify a custom amount of tokens.

Example 1: Add an image to the OpenAI context for use with the Vision API.

ai = openai_add_image(ai, "user", question, image_url, 150)
completion = openai_chat_completion(ai)
text("@completion.response")

When used as a Journey expression it returns a value of type Map:

{
"__type__": "openai/v1",
"max_tokens": 150,
"messages": [
{
"content": [
{
"text": "Describe this image",
"type": "text"
},
{
"image_url": {
"url": {
"__value__": null,
"error": true,
"message": "Unable to generate URL for given ID"
}
},
"type": "image_url"
}
],
"role": "user"
}
]
}

when used with the following context:

%{"ai" => %{"__type__" => "openai/v1", "max_tokens" => nil, "messages" => []}}
card MyCard do
my_var = openai_add_image(ai, "user", "Describe this image", attachment_url(event.message.image.id), 150)

# When used in a piece of text prefix it with an `@`
my_var = "@openai_add_image(ai, \"user\", \"Describe this image\", attachment_url(event.message.image.id), 150)
"
end

openai_add_message(connection, role, content)

Add a single message to the OpenAI context for the given role.

Example 1: Add a single system prompts to the context

When used as a Journey expression it returns a value of type Map:

{
"__type__": "openai/v1",
"messages": [
{
"content": "you are a friendly AI",
"role": "system"
}
]
}

when used with the following context:

%{"ai" => %{"__type__" => "openai/v1", "messages" => []}}
card MyCard do
my_var = openai_add_message(ai, "system", "you are a friendly AI")
# When used in a piece of text prefix it with an `@`
my_var = "@openai_add_message(ai, \"system\", \"you are a friendly AI\")"
end

openai_add_messages(connection, role, messages)

Add a set of messages to the OpenAI context for the given role.

Example 1: Add a series of system prompts to the context

When used as a Journey expression it returns a value of type Map:

{
"__type__": "openai/v1",
"messages": [
{
"content": "you are a friendly AI",
"role": "system"
},
{
"content": "Answer questions as succinctly as possible",
"role": "system"
}
]
}

when used with the following context:

%{"ai" => %{"__type__" => "openai/v1", "messages" => []}}
card MyCard do
my_var = openai_add_messages(ai, "system", ["you are a friendly AI", "Answer questions as succinctly as possible"])
# When used in a piece of text prefix it with an `@`
my_var = "@openai_add_messages(ai, \"system\", [\"you are a friendly AI\", \"Answer questions as succinctly as possible\"])"
end

openai_chat_completion(connection)

Example 1: Make an HTTP call to OpenAI's Chat Completion API and return the generated responses.

When used as a Journey expression it returns a value of type Map:

{
"error": false,
"response": {
"__value__": "the sentences that were generated.\nby OpenAIs model.",
"combined": [
{
"sentence": "the sentences that were generated.",
"type": "sentence"
},
{
"function": {
"arguments": {
"the function": "arguments"
},
"name": "the-function"
},
"type": "function"
},
{
"sentence": "by OpenAIs model.",
"type": "sentence"
}
],
"functions": [
{
"arguments": {
"the function": "arguments"
},
"name": "the-function"
}
],
"sentences": [
"the sentences that were generated.",
"by OpenAIs model."
]
},
"status": 200
}
card MyCard do
my_var = openai_chat_completion(connection)
# When used in a piece of text prefix it with an `@`
my_var = "@openai_chat_completion(connection)"
end

openai_connect(token, model)

Set up a connection to OpenAI's APIs with the given token and the model. The returned value is to be used as the connection for all other openai_* functions.

Example 1: Connect to GPT4 with an API token.

When used as a Journey expression it returns a value of type Map:

{
"__type__": "openai/v1",
"functions": [],
"max_tokens": null,
"messages": [],
"model": "gpt-4",
"token": "sk-XXXXX"
}
card MyCard do
my_var = openai_connect("sk-XXXXX", "gpt-4")
# When used in a piece of text prefix it with an `@`
my_var = "@openai_connect(\"sk-XXXXX\", \"gpt-4\")"
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 Journey expression it returns a value of type Boolean: false when used with the following context:

%{}
card MyCard do
my_var = b or b
# When used in a piece of text prefix it with an `@`
my_var = "@or(b, b)"
end

Example 2:

When used as a Journey expression it returns a value of type String: "a" when used with the following context:

%{"a" => "a", "b" => false}
card MyCard do
my_var = a or b
# When used in a piece of text prefix it with an `@`
my_var = "@or(a, b)"
end

Example 3:

When used as a Journey expression it returns a value of type String: "bee" when used with the following context:

%{"a" => false, "b" => "bee"}
card MyCard do
my_var = a or b
# When used in a piece of text prefix it with an `@`
my_var = "@or(a, b)"
end

Example 4:

When used as a Journey 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 5:

When used as a Journey 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 6: Return the first value that is truthy

When used as a Journey 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 7: Return true if any of the values are true

When used as a Journey 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_datevalue(datetime, format)

Parse random dates and times with strftime patterns and return a DateTime value when it matches.

Example 1: Attempt to parse a date value and return nil when failing

When used as a Journey expression it returns a value of type Null: null.

card MyCard do
my_var = parse_datevalue("👻👻👻👻", "%FT%T%:z")
# When used in a piece of text prefix it with an `@`
my_var = "@parse_datevalue(\"👻👻👻👻\", \"%FT%T%:z\")"
end

Example 2: Parse a date value using strftime formatting and return a DateTime

When used as a Journey expression it returns a value of type DateTime: "2016-02-29T22:25:00Z".

card MyCard do
my_var = parse_datevalue("2016-02-29T22:25:00-00:00", "%FT%T%:z")
# When used in a piece of text prefix it with an `@`
my_var = "@parse_datevalue(\"2016-02-29T22:25:00-00:00\", \"%FT%T%:z\")"
end

parse_float(number)

parse_float(binary)

parse_json(data)

Parses a string as JSON

Example 1:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Null: null.

card MyCard do
my_var = proper(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@proper(nil)"
end

Example 2:

When used as a Journey 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 Journey expression it returns a value of type Integer: 3.

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 Journey expression it returns a value of type String: "".

card MyCard do
my_var = read_digits(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@read_digits(nil)"
end

Example 2:

When used as a Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type String: "".

card MyCard do
my_var = remove_first_word(nil, "-")
# When used in a piece of text prefix it with an `@`
my_var = "@remove_first_word(nil, \"-\")"
end

Example 2:

When used as a Journey expression it returns a value of type String: "".

card MyCard do
my_var = remove_first_word(nil)
# When used in a piece of text prefix it with an `@`
my_var = "@remove_first_word(nil)"
end

Example 3:

When used as a Journey 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 4:

When used as a Journey 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_last_word(binary)

Example 1: Remove the last word from a list of words, using spaces as separator between words

When used as a Journey expression it returns a value of type String: "foo".

card MyCard do
my_var = remove_last_word("foo bar")
# When used in a piece of text prefix it with an `@`
my_var = "@remove_last_word(\"foo bar\")"
end

Example 2: Remove the last word from a list of words, using the specified separator

When used as a Journey expression it returns a value of type String: "foo".

card MyCard do
my_var = remove_last_word("foo-bar", "-")
# When used in a piece of text prefix it with an `@`
my_var = "@remove_last_word(\"foo-bar\", \"-\")"
end

remove_last_word(binary, separator)

remove_numbers(phrase)

Remove numbers

Example 1:

When used as a Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Null: null.

card MyCard do
my_var = rept(nil, 10)
# When used in a piece of text prefix it with an `@`
my_var = "@rept(nil, 10)"
end

Example 2:

When used as a Journey 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 Journey expression it returns a value of type Null: null.

card MyCard do
my_var = right(nil, 3)
# When used in a piece of text prefix it with an `@`
my_var = "@right(nil, 3)"
end

Example 2:

When used as a Journey 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 3:

When used as a Journey 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

round(value)

Example 1: The ROUND function rounds a number to a specified number of digits. For example, if cell A1 contains 23.7825, and you want to round that value to zero decimal places you can do ROUND(23.7825)

When used as a Journey expression it returns a value of type String: "24".

card MyCard do
my_var = ROUND(23.7825)
# When used in a piece of text prefix it with an `@`
my_var = "@ROUND(23.7825)"
end

Example 2: The ROUND function rounds a number to a specified number of digits. For example, if cell A1 contains 23.7825, and you want to round that value to two decimal places you can do ROUND(23.7825, 2)

When used as a Journey expression it returns a value of type String: "23.78".

card MyCard do
my_var = ROUND(23.7825, 2)
# When used in a piece of text prefix it with an `@`
my_var = "@ROUND(23.7825, 2)"
end

round(value, places)

scrub_message_by_id(id)

Permanently scrubs a message by its given ID.

Example 1:

When used as a Journey 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 Journey 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 Journey expression it returns a value of type Integer: 59 when used with the following context:

%{"now" => ~U[2024-09-26 12:17:59.945601Z]}
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 Journey expression it returns a value of type List with values String, String, String:

[
"b",
"a",
"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 Journey 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 Journey 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 Journey expression it returns a value of type Null: null.

card MyCard do
my_var = substitute(nil, "can't", "can do")
# When used in a piece of text prefix it with an `@`
my_var = "@substitute(nil, \"can't\", \"can do\")"
end

Example 2:

When used as a Journey 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 Journey 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

switch(argument1, argument2, argument3)

Example 1: The SWITCH function evaluates one value (called the expression) against a list of values, and returns the result corresponding to the first matching value. If there is no match, an optional default value (the last one in the list if the list is odd) may be returned

When used as a Journey expression it returns a value of type String: "No match".

card MyCard do
my_var = SWITCH(5, 1, "Sunday", 2, "Monday", 3, "Tuesday", "No match")
# When used in a piece of text prefix it with an `@`
my_var = "@SWITCH(5, 1, \"Sunday\", 2, \"Monday\", 3, \"Tuesday\", \"No match\")"
end

Example 2: The SWITCH function evaluates one value (called the expression) against a list of values, and returns the result corresponding to the first matching value. If there is no match, an optional default value (the last one in the list if the list is odd) may be returned

When used as a Journey expression it returns a value of type String: "Sunday".

card MyCard do
my_var = SWITCH(1, 1, "Sunday", 2, "Monday", 3, "Tuesday", "No match")
# When used in a piece of text prefix it with an `@`
my_var = "@SWITCH(1, 1, \"Sunday\", 2, \"Monday\", 3, \"Tuesday\", \"No match\")"
end

time(hours, minutes, seconds)

Defines a time value which can be used for time arithmetic

Example 1:

When used as a Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type Date: "2024-10-08".

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 Journey 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 Journey 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 Journey 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 Journey 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 Journey expression it returns a value of type List with values String, String, String: