Using Transformation functions
Transform functions are used when information received from the user’s input or integration must undergo a transformation before it can be used in the Skill. Luma Virtual Agent provides a set of pre-defined functions that enable the Administrators or the Skill Developers to parse, process, or modify the value provided by the user or integration response and pass the modified value to a Global, Local, or Custom user Attribute. The modified values can also be used to configure payload to execute an action/skill or bot response to the end-user.
For example, you may modify the Date and Time format in the preferred custom format other than the System defined format and present it to the user.
Luma provides a range of Transformation functions to allow skill developers to modify the data as required such as Split, Trim, Substring, Replace, Custom Date-Time, and more.
- 1 How to use Transformation functions?
- 1.1 Split
- 1.2 Trim
- 1.3 Replace - Replace Substring
- 1.4 Replace - Replace First Substring
- 1.5 SubString
- 1.6 Random- Random Number
- 1.7 Random- Random UUID (Uppercase)
- 1.8 Epoch Time - Current UTC Time (ms)
- 1.9 Epoch Time - ISO To Epoch in milliseconds
- 1.10 Epoch Time - ISO To Epoch in seconds
- 1.11 Custom Date format - Using ISO Date Time
- 1.12 Custom Date format - Using Epoch Time
- 1.13 Custom Date format - ISO Zoned Date Time
- 1.14 Custom Date format - Using Epoch Seconds Time
- 1.15 Arithmetic
How to use Transformation functions?
Transformation Functions can be used in the following scenarios:
Building a Skill, as a conversation item
Creating an Integration Operation, in Inbound Response Mapping
Creating a Follow-up, in Data Extraction, Recipients, and Message definition
Using the Transform functions, the Skill Developers/Administrators can extract a string or convert some information into the data, that is required to perform the Skill or the integration.
To add the transformation functions, follow the below steps:
The First step is to add the Set attribute → Transform segment.
When building a Skill, transformation functions can be added to the conversation workflow. Refer to Create Skills for more information on how to create a skill.
On Skill builder-->Conversation flow section, select Set Attribute in Conversation Item.
In the Set Attribute control, select Transform in Add Attribute dropdown.
When creating an Operation, the transformation functions are used in the Inbound mapping section.
On Create Operation--> Response Configuration, select Transform in Add Attribute dropdown.
Once the segment is added to the screen, you may select the transformation function as needed. Besides the function-specific parameters, below details required for each function:
Transform Function: This is the transformation function required. Function Mode, Attribute to Transform and other specific fields appear and are populated based on the selected Transformation function.
Function Mode: Represents the transformation modes available for execution.
Attribute To Transform: Represents the input string to be transformed. You may add a valid attribute or a string to the field.
Scope: This represents the scope of the output Attribute to which the transformed data should be passed. You may assign the value to a Local, Global, or Custom User Attribute.
Attribute: Represents the attribute name.
Data type: Represents the data type of the attribute. In the case of Global and Custom user attributes, the datatype is populated based on the selected attribute’s definition. When using a local attribute, select the data type based on the value to be saved.
The following is are the transformation functions available in the system:
Split
The 'Split’ function can be used to split a text or integration response into smaller strings. It divides the string at the 'delimiter' character and extracts the text at the defined index position from the extracted array. The function returns a set of smaller strings in the order of their occurrence in the string. The extracted strings can then be passed to an attribute.
Add the following details to use the function:
Transformation Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Split | Split | Delimiter: This is the character or expression used to split the string. In the given example, '@' is the delimiting expression. | Consider the input attribute @{user.email} contains value Test@serviceaide.com The logged-in user’s email address in user attribute @{user.email} is split at the character '@' and substring at index position [1] is returned | serviceaide.com |
Index Position: Represents the index position to retrieve the text from the resultant string. |
Trim
The ‘Trim’ function is used to removes blank spaces from the input string or attribute value. It returns a string after removing any leading, trailing, or extra whitespaces. The extracted string can then be passed to an attribute.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Trim | Trim | Not Applicable | Consider, the input string is ”Luma VSA “. | Luma VSA |
Replace - Replace Substring
The ‘Replace’ function finds and replaces a substring with another in the input text. ‘Replace Substring’ function mode is used when we need to replace every occurrence of the substring in the input string. It returns a string after replacing the substring occurrences with the specified substitute string. The replacement starts from the beginning until the end of the string. The extracted string can then be passed to an attribute.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Replace | Replace Substring | Find: Represents the substring to be replaced. In the below example Substring is ‘VSA’ | Consider the input string is ”VSA Luma VSA“ | Virtual Agent Luma Virtual Agent |
Replacement: Represents the substitute string to replace the substring in the Find field. In the below example Substitute Substring is ‘Virtual Agent’. |
Replace - Replace First Substring
The ‘Replace’ function finds and replaces a substring with another in the input text. ‘Replace Substring’ function mode is used when we need to replace the first occurrence of the substring in the input string. It returns a string after replacing the very first occurrence of the substring with the specified substitute string. The replacement starts from the beginning until the end of the string. The extracted string can then be passed to an attribute.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Replace | Replace First Substring | Find: Represents the substring to be replaced. In the below example Substring is ‘VSA’ | Consider the input string is ”VSA Luma VSA“ The very first occurrence of the substring will be replaced with the new string. | Virtual Agent Luma VSA |
Replacement: Represents the substitute string to replace the substring in the Find field. In the below example Substitute Substring is ‘Virtual Agent’. |
The special characters backslash (\) and the dollar sign ($) in the replacement string may cause the transform to be different. Use a regular expression to replace a string or parts of a string.
SubString
The ‘SubString’ function extracts the specified substring from a text string to create another string. The function selects characters between specified locations and returns the same as a new string. The extracted string can then be passed to an attribute.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Substring | Extract | Start Position: Specifies the starting character position in the input string to start extraction. In the below example, the start position is 0. | Consider the input attribute @{user.email} contains the logged-in user’s email address, Test@serviceaide.com. The substring between the specified positions will be extracted into a new string. | Test |
End Position: Specifies the ending character position in the input string to stop extraction. n the below example, the End position is 4 |
Random- Random Number
The ‘Random’ function generates a random number. Random numbers are mostly used for user authentication and verification. For example, the OTP generation used for user authentication. The Random Number function mode is used to generate a random number with the specified number of digits.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Random | Random Number | No of digits: Represents the number of digits required for the random number. In the below example No of digits is set to 5 | The function generates a 5 digit random number. | 57895 (any random number) |
Random- Random UUID (Uppercase)
The Random UUID (Uppercase) function generates a universally unique identifier using hexadecimal code for uppercase characters A to F, which can be saved in an attribute and used while building skills.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Random | Random UUID (Uppercase) | Not applicable | The function generates a unique hexadecimal code Note: The function does not require an input value. | 0DBEE5E0-525E-4A12-8A0D-163657286C7F (a random UUID) |
Epoch Time - Current UTC Time (ms)
The Epoch Time- Current UTC Time (ms) function is used to generate the current system Unix time. The function returns the current Unix time in milliseconds as per the UTC time zone.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Epoch Time | Current UTC Time (ms) | Not applicable | The function returns the current Unix time in milliseconds in UTC timezone Note: The function does not require an input value. | 1600330046722(current time) |
Epoch Time - ISO To Epoch in milliseconds
The Epoch Time - ISO To Epoch in milliseconds function is used to convert ISO time format to Epoch(Unix) time in milliseconds. The function converts the input ISO-8601 time format and returns time in epoch milliseconds format.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Epoch Time | ISO To Epoch in milliseconds | Not applicable | Consider the input string is The function returns the time in epoch milliseconds from the given ISO-8601 time format. | 1594923630000 |
Epoch Time - ISO To Epoch in seconds
The Epoch Time - ISO To Epoch in seconds function is used to convert ISO time format to Epoch(Unix) time in seconds. The function converts the input ISO-8601 time format and returns time in epoch seconds format.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Epoch Time | ISO To Epoch in seconds | Not applicable | Consider the input string is The function returns the Unix time in milliseconds for the specified DateTime in ISO-8601 format. | 1594923630 |
Custom Date format - Using ISO Date Time
Custom Date format function converts ISO date format to the required date-time format. The function returns the input date time in the specified date format such as dd-mm-yyyy, mm-dd-yyyy, and so on.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Custom Date Format | Using ISO Date Time | Format: Represents the date-time format to which the input string should be transformed to. ISO Date Time: Represents the input Date time in ISO 1806 format. Here, you can provide an attribute that holds a DateTime in ISO format or a string. | Consider the input ISO Date Time is The function returns the input time in ISO-8601 time format to d-M-y (date-month-year) | 16-7-2020 |
Custom Date format - Using Epoch Time
Custom Date format function converts the Epoch time to the date-time in the specified zone and format. The function returns the input Epoch time in milliseconds in the specified zone and date format such as d-M-y, M-d-y H m, and so on.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Custom Date Format | Using ISO Date Time | Format: Represents the date-time format to which the input string should be transformed to. Epoch Time (Milliseconds): Represents the input Epoch time in milliseconds, that should be converted to the specified format. Zoneid: Represents the time zone to which the input string should be converted to. For example, America/Sao_Paulo, America/New_York, Asia/Kolkata, Asia/Shanghai, etc. | Consider the input The function returns the input time d-M-y H m (date-month-year Hour minute) | 16-7-2020 23 50 |
Custom Date format - ISO Zoned Date Time
The Custom Date format function converts the ISO Date Time to a specific zone and format. The function returns ISO DateTime in the specified zone.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Custom Date Format | ISO Zoned Date Time | ISO Date Time: Represents the ISO Date time to be converted to the specified format. Here, you can provide an attribute that holds the ISO date time or a string. ZoneId: Represents the time zone to which the input date time should be converted to. For example, America/Sao_Paulo, America/New_York, Asia/Kolkata, Asia/Shanghai, etc. | Consider the input The function returns the date time in selected time zone. | 2021-04-02T01:05:46+05:30 |
Custom Date format - Using Epoch Seconds Time
The Custom Date format function converts the Epoch Time (in seconds) to Date time in a specific zone and format. The function returns DateTime in the specified zone and date format such as d-M-y, M-d-y H m, and so on.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Custom Date Format | Using Epoch Seconds Time | Format: Represents the date-time format to which the input string should be transformed to. Epoch Time (Seconds): Represents the input Epoch time in seconds, that should be converted to the specified format. ZoneId: Represents the time zone to which the input date time should be converted to. For example, America/Sao_Paulo, America/New_York, Asia/Kolkata, Asia/Shanghai, etc. | Consider the input The function returns the date time in selected time zone. | 9-8-2022 16 3 |
Note: Date Time formats should be provided using the below symbols. For Example, Use d-M-y for Date-Month-Year, d/M/y H: m for Date-Month-Year Hours: Minutes.
Arithmetic
The Arithmetic function performs the basic arithmetic operations. Using the operation you perform calculations on numbers like add, subtract, multiply, or divide.
Add the following details to use the function:
Function | Function Mode | Function Specific fields | Example | Result |
---|---|---|---|---|
Arithmetic | Arithmetic | Input Parameters: | Consider the input is: and @{local.counter} holds value 2 The function increments the local variable counter by 1 | 3 |
© 2019 Serviceaide 1-650-206-8988 http://www.serviceaide.com info@serviceaide.com