Handle system-level data using Creatio.ai in the Freedom UI page schema
The example is relevant to Case Management app.
To implement the example:
- Create a case. Read more >>>
- Develop AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier). Read more >>>
- Set up the page UI. Read more >>>
- Set up how to handle case resolution. Read more >>>
Simplify the resolution text of the custom "Creatio instance crashes while uploading files" case using Creatio.ai. Support different tones of simplified text. Out of the box, use formal text tone. Limit the simplified text to 200 characters.
1. Create a case
-
Open the Case Management app in the Application Designer.
-
Open the Advanced settings tab in the Application Designer. To do this, click
in the top right → Application management → Application Hub → Case Management app → Advanced settings. -
Create a user-made package to develop AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier). To do this, click
→ Create new package → fill out the package properties → Save.For this example, create the
sdkCreatioAIInFreedomUIuser-made package. -
Change the current package. Instructions: Change the current package.
For this example, change the current package to
sdkCreatioAIInFreedomUIuser-made package. -
Open the Cases section.
-
Add a new case. To do this, click New.
-
Fill out the case properties.
Property
Property value
Contact*
John Best
Account
Our company
General info tab
Subject*
Creatio instance crashes while uploading files
Description
The Creatio instance constantly crashes when trying to upload a file larger than 10 MB to the server. The issue seems to be with the file handling method not releasing resources after the upload is complete. In some cases, uploading a file also leads to a system timeout, with the connection closing before the process ends. It makes it difficult to determine the exact cause.
Closure and feedback tab
Resolution
Upon further analysis, it was identified that the file upload function is not properly disposing of memory stream objects after the file is uploaded. The memory stream was held in memory, resulting in excessive memory consumption and eventually leading to out-of-memory exceptions. Furthermore, due to improper exception handling in a multithreading implementation, multiple threads attempting to access shared resources during concurrent uploads caused deadlocks, which in turn triggered timeouts as connections waited indefinitely for resource locks to be released.
We solved this issue by implementing a more efficient memory management strategy, ensuring that all threads are explicitly disposed of after use. We implemented more efficient "try-finally" blocks to ensure that the cleanup logic is executed even in the event of an unexpected failure. We also introduced a semaphore to limit the number of concurrent downloads, preventing the server from overloading due to insufficient resources. Finally, we added more detailed logging to capture thread state and memory usage during the upload process for future troubleshooting. -
Select the "In progress" status on the progress bar. This saves the case.
As a result, Creatio will add the "Creatio instance crashes while uploading files" case to the Cases section.

2. Develop AI Sub-agent
-
Open the Creatio.ai sub-agents (Creatio.ai skills in Creatio 8.3.3 and earlier) section. To do this, click
in the top right → System setup → Creatio.ai sub-agents (Creatio.ai skills in Creatio 8.3.3 and earlier). -
Add an AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier). To do this, click New.
-
Fill out the properties of the AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier).
The Code property is populated automatically.
Property
Property value
Title*
Simplify the case resolution
Code*
UsrSkillSimplifyTheCaseResolution
Description*
AI Sub-agent that simplifies the case resolution
Status*
Active
Where to use* (Usage mode in Creatio 8.3.2 and earlier)
"Workflows" ("API" in Creatio 8.3.2 and earlier)
-
Specify the user's goal when using the AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier).
Property
Property value
Prompt
Your task is to simplify the following case resolution:
inputText. Use thetextTonetext tone and limit the simplified text to 200 characters. -
Save the changes.
As a result, Creatio will add the "Simplify the case resolution" AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier) to the Creatio.ai sub-agents (Creatio.ai skills in Creatio 8.3.3 and earlier) section.

3. Set up the page UI
-
Open the Case Management app in the Application Designer.
-
Open the Cases form page.
-
Open the Closure and feedback tab.
-
Add a field.
For this example, add the field that contains the text tone to simplify the case resolution. To do this:
-
Add a field of needed type to the canvas.
-
Click
and fill out the field properties.Element
Element type
Property
Property value
Field that contains the text tone to simplify the case resolution
Text
Title on page
Resolution tone
-
-
Add a button.
For this example, add the button that calls the "Simplify the case resolution" AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier).
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 "Simplify the case resolution" AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier)
Title
Simplify the resolution
Style
Outline
-
-
Save the changes.
4. Set up how to handle case resolution
Configure the business logic in the Client Module Designer. For this example, set up how to handle case resolution.
-
Click
→ Source code to open the page source code of the Freedom UI page. -
Add the dependencies. To do this, add
@creatio-devkit/commonlibrary as a dependency.AMD module dependencies/* Declare the AMD module. */define("Cases_FormPage", /**SCHEMA_DEPS*/["@creatio-devkit/common"] /**SCHEMA_DEPS*/,function/**SCHEMA_ARGS*/(sdk)/**SCHEMA_ARGS*/ {return {...}}); -
Add an attribute.
- Go to the
viewModelConfigDiffschema section →valuesconfiguration object. - Add a
IsCreatioAIElementsVisibleattribute that stores visibility data of the Resolution tone field and Simplify the resolution button. Out-of-the-box, the field and button are not visible. - Add a
ResolutionToneattribute that stores data of the text tone to simplify the case resolution. Out-of-the-box, the text tone to simplify the case resolution is formal.
viewModelConfigDiff schema sectionviewModelConfigDiff: /**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/[{"operation": "merge","path": ["attributes"],"values": {...,/* The attribute that stores visibility data of the "Resolution tone"field and "Simplify the resolution" button. */"IsCreatioAIElementsVisible": {"value": false},/* The attribute that stores data of the text tone to simplifythe case resolution. */"ResolutionTone": {"value": 'Formal'},}},...]/**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/, - Go to the
-
Set up how to handle the action executed on button click.
- Go to the
viewConfigDiffschema section →UsrSimplifyResolutionButtonelement. - Bind the sending of the custom
usr.SimplifyTextrequest to theclickedbutton event.
viewConfigDiff schema sectionviewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[/* Button that calls the "Simplify the case resolution" AI Sub-agent(AI Skill in Creatio 8.3.3 and earlier). */{"operation": "insert","name": "UsrSimplifyResolutionButton","values": {...,"clicked": {/* Bind the sending of the custom request to the "clicked"button event. */"request": "usr.SimplifyText"}},...}]/**SCHEMA_VIEW_CONFIG_DIFF*/, - Go to the
-
Bind an attribute to the page elements.
- Go to the
viewConfigDiffschema section →UsrResolutionToneFieldelement. - Bind the
$IsCreatioAIElementsVisibleattribute to thevisibleproperty. - Bind the
$ResolutionToneattribute to thecontrolproperty. - Go to the
UsrSimplifyResolutionButtonelement. - Bind the
$IsCreatioAIElementsVisibleattribute to thevisibleproperty.
viewConfigDiff schema sectionviewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[...,/* Field that contains the text tone to simplify the case resolution. */{"operation": "insert","name": "UsrResolutionToneField","values": {...,"control": "$ResolutionTone",/* The property that flags the field as visible. Bound to the"IsCreatioAIElementsVisible" attribute. */"visible": "$IsCreatioAIElementsVisible",},...},/* Button that calls the "Simplify the case resolution" AI Sub-agent(AI Skill in Creatio 8.3.3 and earlier). */{"operation": "insert","name": "UsrSimplifyResolutionButton","values": {...,/* The property that flags the button as visible. Bound to the"IsCreatioAIElementsVisible" attribute. */"visible": "$IsCreatioAIElementsVisible",},...},...,]/**SCHEMA_VIEW_CONFIG_DIFF*/, - Go to the
-
Implement the request handlers.
-
Go to the
handlersschema section. -
Add a custom implementation of the
crt.HandleViewModelInitRequestbase request handler.- Wait for the rest of the initialization handlers to finish.
- Specify code of the "Simplify the case resolution" AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier).
- Retrieve the instance of the HTTP client from
@creatio-devkit/common. - Send the
crt.CopilotGetAvailableIntentsRequestbase request that checks the accessibility of the AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier). - If the list of AI Sub-agents (AI Skills in Creatio 8.3.3 and earlier) includes the AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier) whose code is
UsrSkillSimplifyTheCaseResolution, set theIsCreatioAIElementsVisibleattribute to the index of the corresponding AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier).
-
Implement the
usr.EditEventRequestcustom request handler.- Retrieve the instance of the HTTP client from
@creatio-devkit/common. - Send the
crt.CopilotExecuteIntentRequestbase request that runs the AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier). - Specify code of the "Simplify the case resolution" AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier).
- Specify parameters of the "Simplify the case resolution" AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier). The
StringAttribute_qmmwomsattribute stores data of the Resolution field. - If Creatio can run the AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier), AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier) simplifies the case resolution. Otherwise, handle the status of the Creatio.ai execution, display the error and warning messages if error or warning occur during the AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier) execution.
- Call the next handler if it exists and return its result.
- Retrieve the instance of the HTTP client from
handlers schema sectionhandlers: /**SCHEMA_HANDLERS*/[{request: "crt.HandleViewModelInitRequest",/* Custom implementation of a base request handler. */handler: async (request, next) => {/* Wait for the rest of the initialization handlers to finish. */await next?.handle(request);/* Code of the AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier). */const skillName = 'UsrSkillSimplifyTheCaseResolution';/* Retrieve the instance of the HTTP client from "@creatio-devkit/common." */const handlerChain = sdk.HandlerChainService.instance;/* Send the base request that checks the accessibility of the AISub-agent (AI Skill in Creatio 8.3.3 and earlier). */var result = await handlerChain.process({type: 'crt.CopilotGetAvailableIntentsRequest',intentNames: [skillName],$context: request.$context,scopes: [...request.scopes]});/* If the list of AI Sub-agents (AI Skills in Creatio 8.3.3 andearlier) includes the AI Sub-agent (AI Skill in Creatio 8.3.3 andearlier) whose code is "UsrSkillSimplifyTheCaseResolution," setthe "IsCreatioAIElementsVisible" attribute to the index of thecorresponding AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier). */request.$context.IsCreatioAIElementsVisible = result.availableIntentNames.indexOf(skillName) > -1;}},{request: "usr.SimplifyText",/* Implement the custom request handler. */handler: async (request, next) => {const context = request.$context;/* Retrieve the instance of the HTTP client from "@creatio-devkit/common." */const handlerChain = sdk.HandlerChainService.instance;/* Send the base request that runs the AI Sub-agent (AI Skill inCreatio 8.3.3 and earlier). */const copilotCallResult = await handlerChain.process({type: 'crt.CopilotExecuteIntentRequest',/* Code of the AI Sub-agent (AI Skill in Creatio 8.3.3 andearlier) to run. */intentName: 'UsrSkillSimplifyTheCaseResolution',/* Parameters of the AI Sub-agent (AI Skill in Creatio 8.3.3and earlier). */parameters: {inputText: await context.StringAttribute_qmmwoms,textTone: await context.ResolutionTone},$context: request.$context,scopes: [...request.scopes]});/* If Creatio can run the AI Sub-agent (AI Skill in Creatio 8.3.3and earlier), AI Sub-agent (AI Skill in Creatio 8.3.3 and earlier)simplifies the case resolution. */if (copilotCallResult.isSuccess) {request.$context.StringAttribute_qmmwoms = copilotCallResult.content;} else {/* If the status of the AI Sub-agent (AI Skill in Creatio 8.3.3and earlier) execution is "FailedToExecute," the browser consoledisplays the "Error occurs during the AI Sub-agent (AI Skillin Creatio 8.3.3 and earlier) execution" error message.Otherwise, implement a business logic that uses a predefined"errorMessage" value depending on your business goals. */if(copilotCallResult.status == 'FailedToExecute'){console.error(copilotCallResult.errorMessage);alert("Error occurs during the AI Skill execution");} else {alert(copilotCallResult.errorMessage);};}/* If warning occurs during the AI Sub-agent (AI Skill in Creatio8.3.3 and earlier) execution, the browser console displays the listof warnings. Many messages are separated by comma. */if(copilotCallResult.warnings.length > 0){console.warn(copilotCallResult.warnings.join(', '));}/* Call the next handler if it exists and return its result. */return next?.handle(request);}}]/**SCHEMA_HANDLERS*/, -
-
Save the changes.
View the result
To view the result of the example that uses an out-of-the-box text tone to simplify the case resolution:
- Open the Cases section.
- Open the "Creatio instance crashes while uploading files" case.
- Click Simplify the resolution.
As a result, Creatio.ai will simplify the case resolution using out-of-the-box text tone and add simplified text to the Resolution field. The simplified text is limited to 200 characters.
If you need, edit the Resolution field value provided by Creatio.ai.
To view the result of the example that uses custom text tone to simplify the case resolution:
- Open the Cases section.
- Open the "Creatio instance crashes while uploading files" case.
- Change the text tone to simplify the case resolution. For example, "Friendly."
- Click Simplify the resolution.
As a result, Creatio.ai will simplify the case resolution using custom text tone and add simplified text to the Resolution field. The simplified text is limited to 200 characters.