https://automate.help.sentione.com/docs/strings#sliceindexstartindexendA string is an ordered sequence of one or more characters that may consist of letters, numbers, or symbols. A string can contain any sequence of characters, visible or invisible, and characters may be repeated.

In other words, a string is any text.

In Expression language, strings are contained within double quotation marks.

Examples of strings:

  • "Robert California"
  • "33 times"
  • "$30 for you."
  • "["
  • "@#$"
  • "{this is not an object nor expression, it's just a string, because it's contained in quotation marks}"

In Automate, strings can be found in any of the input fields, eg. Responses, output conditions, or values saved to Memory.

String methods

MethodDescription
LiteralsA string literal is a sequence of characters in double quotes (if in the input fields).
ConcatenationJoins many strings by using the + operator
Escape characterAllows adding { } if in response text, and " or { } in the input fields, by using the escape character ****
InterpolationAllows you to inject some value into a string
replace(old,new)Allows you to replace some parts of string
toDateTime(format)Converts a string into DateTime value
toLower()Changes all characters to lower case
toUpper()Changes all characters to upper case
toNumber()Converts a string into a numeric value (either round number or with decimal points)
length()Returns length (number of characters) of the string
contains(searchString)Determines whether or not the string includes searchString.
slice(indexStart, indexEnd)Returns a new string containing the extracted section of the string.

Literals

A string literal is a sequence of characters in double quotes.

When adding it to the input field, adding the double quotes is necessary when the string consists of more words or has a space in it. It is also possible to create an empty string using "".

In the response field, double quotes are not needed as the string will be printed in any case.

"I would like to make a transfer"
868

Concatenation

Concatenation allows you to concatenate more strings together.

In the input fields, to join strings you can use + operator

"I would like to make a transfer to" + recipient.name + " for the value of " + recipient.amount
// Assumptions
// recepient.name = "Adam" 
// recepient.amount = 100

 "I would like to make a transfer to Adam for the amount of 100"
768

In the responses, to join many strings you can use interpolation.

Interpolation

Interpolation allows you to inject some value into a string.

"Hello {nlu.variables.name}!"
// Assumptions
// nlu.variables.name = "Adam"

"Hello Adam!"

When used in the response, the double quotes are not needed, but the variable or strings that needs to be added needs to go within curly brackets { }.

1388

Escape character

The escape character \ allows you to add in the response or the input field, some values that otherwise would not be printed or cause errors.

Hello! Today is a beautiful \"day\"
Hello! Today is a beautiful "day"

In case of the response field, double quotes are printed (no need to add an escape character) but curly brackets are not. Therefore, to add { } to your response, that is, to make sure they are printed, you need to add \ .

🚧

Note that you need to escape every character with \ for it to work.

368

In case of input field, neither " nor { } are printed, so if you would like to use them you have to use escape character \ in both cases.

replace(old,new)

To replace some parts of the string used

"Hello people".replace("people", "world")
"Hello world"
1742

toDateTime(format)

Converts a string into a DateTime value. More info here.

"2010-06-30T01:20+02:00".toDateTime()
"2010-06-30 01:20"

toLower()

Change all characters to lower case.

"HeLLo WoRLd".toLower()
"hello world"
1178

toUpper()

Change all characters to upper case.

"hello world".toUpper()
"HELLO WORLD"
1154

toNumber()

Converts a string into numeric value (either round number or with decimal points)

"10.5".toNumber()
10.50
1764

length()

Returns length (number of characters) of the string

"Automate".length()
8

contains(searchString)

Performs a case-sensitive search to determine if searchString can be found inside this string. Returns true if found, otherwise false.

"Automate is awesome!".contains("Automate")
"Automate is awesome!".contains("SentiOne")
true
false

slice(indexStart, indexEnd)

Returns a new string containing the extracted section (up to indexEnd, which is optional) of the string. If indexEnd is not set, then returned string contains characters from indexEnd till the end of the string.

Method works the same way as JavaScript slice method, so please refer to it's documentation.

"Automate is awesome!".slice(0, 8)
"Automate is awesome!".slice(12)
"Automate is awesome!".slice(-8)
"Automate"
"awesome!"
"awesome!"

What’s Next