Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Current »

Luma provides a set of pre-defined functions that enable Administrator/Developer to parse, process and modify user text response or JSON response received by the system. The modified response can be used to configure payload to execute an action/skill.

These functions are available in ‘Skill builder’ module and can be invoked by typing ‘@fn.’ on Text Response field on ‘Skill Builder’ screen.

Below are the available functions:

  • Split

  • Substring

  • Replace

  • Random number

Split function

‘Split’ function can be used to split a text or JSON response into smaller strings while building a skill. On ‘Skill Builder’ page- Text Responses section, use @fn.split function to split a string in an attribute at a specified position.

Function

Syntax

Example

Result

Split()

@fn.split(' '.split(' '))

Consider @context.Email_Address holds 'John@test.com', then:

@fn.split('@context.Email_Address'.split('@')[0])

John

Substring function

‘Substring’ function extracts characters from a text string to create another string. The function selects characters between specified locations and returns the same as a new string. On ‘Skill Builder’ page- Text Responses section, use @fn.substring function to select a substring from an attribute value.

Function

Syntax

Example

Result

Substring

@fn.substring(' '.substring( , ))

Consider @context.OrgName holds 'Serviceaide', then:

@fn.substring('@context.OrgName'.substring(0,'@context.OrgName'.length()-4))

Service

Replace function

‘Replace’ function replaces characters specified by location in a given text string with another text string. On ‘Skill Builder’ page- Text Responses section, use @fn.replace function to replace a part of the text response with another string. Note that the function does an exact match and is case sensitive.

Function

Syntax

Example

Result

Replace

@fn.replace(' '.replace(' ',' '))

Consider @context.Email_Address holds 'John@test.com', then:

@fn.replace('@context.Email_Address'.replace('test','serviceaide'))

John@serviceaide.com

Random Number

RandomNumber function generates a 4-digit random number that can be saved in an attribute for later action while building skills. Random numbers are mostly used for user authentication and verification. For example, OTP generation used for user authentication.

On Skill Builder page- Text Responses section, use @fn.randomNumber function to generate a 4 digit random number.

Function

Syntax

Example

Result

randomNumber

@fn.randomNumber

@fn.randomNumber

3463

  • No labels