Handle system-level data using Creatio AI in the back-end
To implement the example:
- Develop AI Skill. Read more >>>
- Implement a business process that runs the AI Skill. Read more >>>
- Set up the page UI. Read more >>>
Display summarized information of a specific contact on a "Retrieve the summarized contact information" page. The "Summarize contact information" business process generates the "Retrieve the summarized contact information" page and handles the retrieved data by Creatio AI. The page has the following parameters:
- Outcome of the Creatio AI work that contains the Full name, Birth date, Full job title, Business phone of the first contact in the contact list. The data is handled by Creatio AI.
- Status of the Creatio AI execution
- Error message (Creatio AI)
- Error message (
inputText
parameter)
1. Develop AI Skill
-
Open the Customer 360 app in the No-Code Designer.
-
Open the Advanced settings tab in the No-Code Designer. To do this, click in the top right → Application management → Application Hub → Customer 360 app → Advanced settings.
-
Create a user-made package to develop AI Skill. To do this, click → Create new package → fill out the package properties → Save.
For this example, create the
sdkCreatioAIInScriptTask
user-made package. -
Change the current package. Instructions: Change the current package.
For this example, change the current package to
sdkCreatioAIInScriptTask
user-made package. -
Open the Copilot setup section. To do this, click in the top right → System setup → Copilot setup.
-
Add an AI Skill. To do this, click New.
-
Fill out the properties of the AI Skill.
Property
Property value
Title*
Contact summary
Code*
UsrContactSummary
Description*
AI Skill that summarizes contact information
Status*
Active
Usage mode*
API
-
Specify the user's goal when using the AI Skill.
Property
Property value
Prompt
Your task is to summarize the following contact information:
[# inputText #]
. -
Save the changes.
As a result, Creatio will add the "Contact summary" AI Skill to the Copilot setup section.
2. Implement a business process that runs the AI Skill
1. Create a business process
-
Open the Customer 360 app in the No-Code Designer.
-
Open the Advanced settings tab in the No-Code Designer. To do this, click in the top right → Application management → Application Hub → Customer 360 app → Advanced settings.
-
Select a user-made package to create a business process.
For this example, select the
sdkCreatioAIInScriptTask
user-made package. -
Create the business process schema. To do this, click Add → Business process.
-
Open the Settings tab.
-
Fill out the schema properties.
For this example, use the schema properties as follows.
Property
Property value
Title
Summarize contact information
Code
UsrSummarizeContactInformation
-
Save the changes.
As a result:
- The "Summarize contact information" business process will be created.
- Creatio will add the "Summarize contact information" business process to the Process library section.
2. Set up the business process parameters
-
Open the properties of the business process schema. To do this, click an arbitrary place in the working area of the Process Designer.
-
Open the Parameters tab.
-
Add the business process parameters.
For this example, add the following parameters:
- parameter that contains the contact name whose information needs to be summarized
- parameter that contains the
inputText
parameter of the AI Skill - parameter that contains the outcome of the Creatio AI work
- parameter that contains the error message if error occurs during the AI Skill execution
- parameter that contains the error message if the
inputText
parameter of the AI Skill is empty or it has incorrect format - parameter that contains the status of the Creatio AI execution
To do this:
-
Click Add parameter and select a parameter of the needed type.
-
Fill out the parameter properties.
Element
Element type
Property
Property value
Parameter that contains the contact name whose information needs to be summarized
Lookup
Title
Contact
Code
ContactName
Data type
Lookup
Lookup
Contact
Direction
Input
Parameter that contains the
inputText
parameter of the AI SkillText
Title
inputText
parameter of the the AI SkillCode
InputTextParameter
Data type
Text (500 characters)
Direction
Internal
Parameter that contains the outcome of the Creatio AI work
Text
Title
Outcome of the Creatio AI work
Code
CreatioAIResult
Data type
Text (500 characters)
Direction
Output
Parameter that contains the error message if error occurs during the AI Skill execution
Text
Title
Error message (Creatio AI)
Code
CreatioAIErrorMessage
Data type
Text (500 characters)
Direction
Output
Parameter that contains the message if the
inputText
parameter of the AI Skill is empty or it has incorrect formatText
Title
Error message (
inputText
parameter)Code
InputTextParameterErrorMessage
Data type
Text (500 characters)
Direction
Output
Parameter that contains the status of the Creatio AI execution
Text
Title
Status of the Creatio AI execution
Code
ExecutionStatus
Data type
Text (500 characters)
Direction
Output
As a result, the Parameters tab of the "Summarize contact information" business process will be as follows.
3. Set up the business process methods
-
Open the properties of the business process. To do this, click an arbitrary place in the working area of the Process Designer.
-
Open the Methods tab.
-
Add the business process methods.
-
Click and fill out the method properties.
Property
Property value
Namespace
Creatio.Copilot
-
Click Save.
-
-
Save the changes.
As a result, the Methods tab of the "Summarize contact information" business process will be as follows.
4. Implement reading contact information
-
Add a Read data element. To do this, click → place the Read data element between the Simple and Terminate page elements in the working area of the Process Designer.
-
Fill out the element properties.
Property
Property value
Title
Read contact information
Which object to read data from?
Contact
How to filter records?
- Click Add condition. This opens the Select column window.
- Select "Id" in the Column property.
- Click Select.
- Select Compare with Parameter. This opens the Select parameter window.
- Select the parameter. To do this, open the Process parameters tab → click Contact → Select.
Leave default values for other element properties.
-
Save the changes.
As a result:
-
The setup area of the "Read contact information" element will be as follows.
-
The diagram of the "Summarize contact information" business process will be as follows.
5. Implement creating the inputText parameter of the AI Skill
-
Add a Formula element. To do this, click → place the Formula element between the Read data system action and Terminate page element in the working area of the Process Designer.
-
Fill out the element properties.
Property
Property value
Title
Create the
inputText
parameterWhich parameter to set the formula value to?
Click → Process parameters tab →
inputText
parameter of the AI Skill → Select.Formula value
-
Click . This opens the Formula window.
-
Add the formula:
"Full name: " + [#Read contact information.First item of resulting collection.Full name#] + " Birth date: " + [#Read contact information.First item of resulting collection.Birth date#] + " Full job title: " + [#Read contact information.First item of resulting collection.Full job title#] + " Business phone: " + [#Read contact information.First item of resulting collection.Business phone#]
-
Save the changes.
-
-
Save the changes.
As a result:
-
The setup area of the "Create the
inputText
parameter" element will be as follows. -
The diagram of the "Summarize contact information" business process will be as follows.
6. Implement running the AI Skill
-
Add a Script task element. To do this, click → place the Script task element between the Formula system action and Terminate page element in the working area of the Process Designer.
-
Fill out the element properties.
Property
Property value
Title
Run the AI Skill
-
Implement the logic of working with process parameters. To do this, go to the element setup area and add the source code.
Run the AI Skill script task// IMPORTANT: When implementing
// long-running operations,
// it is crucial to enable timely and
// responsive cancellation. To achieve
// this, ensure that your code
// is designed to respond appropriately
// to cancellation requests using
// the context.CancellationToken
// mechanism. For more detailed
// information and examples,
// please, refer to our documentation.
/* Retrieve the "inputText" parameter of the AI Skill. */
var infoToSend = Get<string>("InputTextParameter");
/* Create an "CopilotIntentCall" instance. */
var request = new CopilotIntentCall {
/* Code of the AI Skill to run. */
IntentName = "UsrContactSummary",
/* Parameters of the AI Skill. */
Parameters = new Dictionary<string, object> {
{ "inputText", infoToSend }
}
};
/* Create an instance of the "CopilotIntentCall" object. */
CopilotIntentCallResult result = UserConnection.CopilotEngine.ExecuteIntent(request);
/* Status of the Creatio AI execution. */
Set("ExecutionStatus", result.Status.ToString());
/* Display the message if the "inputText" parameter of the AI Skill is empty or it has incorrect format. Many messages are separated by semicolon. */
if (result.Warnings.Count > 0) {
Set("InputTextParameterErrorMessage", string.Join(";", result.Warnings));
}
/* Display the error message if error occurs during the AI Skill execution. */
if (!result.IsSuccess) {
Set("CreatioAIErrorMessage", result.ErrorMessage);
return true;
}
/* Outcome of the Creatio AI work. */
Set("CreatioAIResult", result.Content);
return true; -
Save the changes.
-
Publish the changes.
As a result, the diagram of the "Summarize contact information" business process will be as follows.
7. Implement a separate page to display the outcome of the Creatio AI work
-
Add an auto-generated page.
-
Click → place the Auto-generated page element between the Script task system action and Terminate page element in the working area of the Process Designer.
-
Fill out the element properties.
Property
Property value
Title
Retrieve the summarized contact information
Page title
Retrieve the summarized contact information
Creatio populates the Contact property using the "[#System variable.Current user contact#]" value.
-
-
Add the parameters of the AI Skill.
For this example, add the following parameters:
- parameter that contains the outcome of the Creatio AI work
- parameter that contains the status of the Creatio AI execution
- parameter that contains the error message if error occurs during the AI Skill execution
- parameter that contains the message if the
inputText
parameter of the AI Skill is empty or it has incorrect format
To do this:
-
Go to the Page Items block.
-
Click and select a parameter of the needed type.
-
Fill out the parameter properties.
Element
Element type
Property
Property value
Parameter that contains the outcome of the Creatio AI work
Text field
Title
Outcome of the Creatio AI work
Code
CreatioAIResult
Is multiline
Select the checkbox
Value
Click → Process parameter → Process parameters tab → Outcome of the Creatio AI work → Select. This populates the property using the "[#Outcome of the Creatio AI work#]" value.
Parameter that contains the status of the Creatio AI execution
Text field
Title
Status of the Creatio AI execution
Code
ExecutionStatus
Value
Click → Process parameters → Process parameters tab → Status of the Creatio AI execution → Select. This populates the property using the "[#Status of the Creatio AI execution#]" value.
Parameter that contains the error message if error occurs during the AI Skill execution
Text field
Title
Error message (Creatio AI)
Code
CreatioAIErrorMessage
Value
Click → Process parameters → Process parameters tab → Error message (Creatio AI) → Select. This populates the property using the "[#Error message (Creatio AI)#]" value.
Parameter that contains the message if the
inputText
parameter of the AI Skill is empty or it has incorrect formatText field
Title
Error message (
inputText
parameter)Code
InputTextParameterErrorMessage
Value
Click → Process parameters → Process parameters tab → Error message (
inputText
parameter) → Select. This populates the property using the "[#Error message (inputText
parameter)#]" value.
As a result, the Page Items property block of the "Retrieve the summarized contact information" auto-generated page will be as follows.
As a result, the diagram of the "Summarize contact information" business process will be as follows.
8. Ensure that the business process works as expected
- Open the Process library section. To do this, click → Processes → Process library.
- Select the "Summarize contact information" business process in the section list.
- Run the business process. To do this, click Run.
As a result:
-
Creatio will run a "Summarize contact information" business process.
-
The "Summarize contact information" business process will generate a "Retrieve the summarized contact information" page.
-
The "Retrieve the summarized contact information" page will include the summarized contact information of the first contact in the contact list provided by Creatio AI.
3. Set up the page UI
-
Open the Customer 360 app in the No-Code Designer.
-
Open the Contacts form page.
-
Add a button.
For this example, add the button that calls the "Summarize contact information" business process.
To do this:
-
Add a Button type component to the toolbar of the Freedom UI Designer.
-
Click and fill out the button properties.
Element
Property
Property value
Button that calls the "Summarize contact information" business process
Title
Create summary
Style
Outline
Action
Run process
Which process to run?
Summarize contact information
How to run the process?
For the selected page
-
-
Save the changes.
View the result
- Open the Contacts section.
- Open a contact that has an arbitrary name. For example, "Alice Phillips."
- Click Create summary.
As a result, Creatio will display the "Retrieve the summarized contact information" page that include the summarized information of a specific contact. View the result >>>
Source code
- Run the AI Skill script task
- Contacts_FormPage
// IMPORTANT: When implementing
// long-running operations,
// it is crucial to enable timely and
// responsive cancellation. To achieve
// this, ensure that your code
// is designed to respond appropriately
// to cancellation requests using
// the context.CancellationToken
// mechanism. For more detailed
// information and examples,
// please, refer to our documentation.
/* Retrieve the "inputText" parameter of the AI Skill. */
var infoToSend = Get<string>("InputTextParameter");
/* Create an "CopilotIntentCall" instance. */
var request = new CopilotIntentCall {
/* Code of the AI Skill to run. */
IntentName = "UsrContactSummary",
/* Parameters of the AI Skill. */
Parameters = new Dictionary<string, object> {
{ "inputText", infoToSend }
}
};
/* Create an instance of the "CopilotIntentCall" object. */
CopilotIntentCallResult result = UserConnection.CopilotEngine.ExecuteIntent(request);
/* Status of the Creatio AI execution. */
Set("ExecutionStatus", result.Status.ToString());
/* Display the message if the "inputText" parameter of the AI Skill is empty or it has incorrect format. Many messages are separated by semicolon. */
if (result.Warnings.Count > 0) {
Set("InputTextParameterErrorMessage", string.Join(";", result.Warnings));
}
/* Display the error message if error occurs during the AI Skill execution. */
if (!result.IsSuccess) {
Set("CreatioAIErrorMessage", result.ErrorMessage);
return true;
}
/* Outcome of the Creatio AI work. */
Set("CreatioAIResult", result.Content);
return true;
/* Declare the AMD module. */
define("Contacts_FormPage", /**SCHEMA_DEPS*/[]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/()/**SCHEMA_ARGS*/ {
return {
viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
/* Button that calls the "Summarize contact information" business process. */
{
"operation": "insert",
"name": "UsrCreateSummaryButton",
"values": {
"type": "crt.Button",
"caption": "#ResourceString(Button_wm51pwk_caption)#",
"color": "outline",
"disabled": false,
"size": "large",
"iconPosition": "only-text",
"visible": true,
"clicked": {
"request": "crt.RunBusinessProcessRequest",
"params": {
"processName": "UsrSummarizeContactInformation",
"processRunType": "ForTheSelectedPage",
"showNotification": true,
"recordIdProcessParameterName": "ContactName"
}
},
"clickMode": "default"
},
"parentName": "ActionButtonsContainer",
"propertyName": "items",
"index": 0
}
]/**SCHEMA_VIEW_CONFIG_DIFF*/,
viewModelConfigDiff: /**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/[]/**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/,
modelConfigDiff: /**SCHEMA_MODEL_CONFIG_DIFF*/[]/**SCHEMA_MODEL_CONFIG_DIFF*/,
handlers: /**SCHEMA_HANDLERS*/[]/**SCHEMA_HANDLERS*/,
converters: /**SCHEMA_CONVERTERS*/{}/**SCHEMA_CONVERTERS*/,
validators: /**SCHEMA_VALIDATORS*/{}/**SCHEMA_VALIDATORS*/
};
});