Skip to main content
Version: 8.2

Handle system-level data using Creatio AI in the back-end

Level: advanced

To implement the example:

  1. Develop AI Skill. Read more >>>
  2. Implement a business process that runs the AI Skill. Read more >>>
  3. Set up the page UI. Read more >>>
Example

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

  1. Open the Customer 360 app in the No-Code Designer.

  2. Open the Advanced settings tab in the No-Code Designer. To do this, click in the top right → Application managementApplication HubCustomer 360 app → Advanced settings.

  3. 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.

  4. Change the current package. Instructions: Change the current package.

    For this example, change the current package to sdkCreatioAIInScriptTask user-made package.

  5. Open the Copilot setup section. To do this, click in the top right → System setupCopilot setup.

  6. Add an AI Skill. To do this, click New.

  7. 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

  8. Specify the user's goal when using the AI Skill.

    Property

    Property value

    Prompt

    Your task is to summarize the following contact information: [# inputText #].

  9. 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

  1. Open the Customer 360 app in the No-Code Designer.

  2. Open the Advanced settings tab in the No-Code Designer. To do this, click in the top right → Application managementApplication HubCustomer 360 app → Advanced settings.

  3. Select a user-made package to create a business process.

    For this example, select the sdkCreatioAIInScriptTask user-made package.

  4. Create the business process schema. To do this, click AddBusiness process.

  5. Open the Settings tab.

  6. Fill out the schema properties.

    For this example, use the schema properties as follows.

    Property

    Property value

    Title

    Summarize contact information

    Code

    UsrSummarizeContactInformation

  7. 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

  1. Open the properties of the business process schema. To do this, click an arbitrary place in the working area of the Process Designer.

  2. Open the Parameters tab.

  3. 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:

    1. Click Add parameter and select a parameter of the needed type.

    2. 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 Skill

      Text

      Title

      inputText parameter of the the AI Skill

      Code

      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 format

      Text

      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

  1. Open the properties of the business process. To do this, click an arbitrary place in the working area of the Process Designer.

  2. Open the Methods tab.

  3. Add the business process methods.

    1. Click and fill out the method properties.

      Property

      Property value

      Namespace

      Creatio.Copilot

    2. Click Save.

  4. 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

  1. 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.

  2. Fill out the element properties.

    Property

    Property value

    Title

    Read contact information

    Which object to read data from?

    Contact

    How to filter records?

    1. Click Add condition. This opens the Select column window.
    2. Select "Id" in the Column property.
    3. Click Select.
    4. Select Compare with Parameter. This opens the Select parameter window.
    5. Select the parameter. To do this, open the Process parameters tab → click ContactSelect.

    Leave default values for other element properties.

  3. 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

  1. 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.

  2. Fill out the element properties.

    Property

    Property value

    Title

    Create the inputText parameter

    Which parameter to set the formula value to?

    Click Process parameters tab → inputText parameter of the AI SkillSelect.

    Formula value

    1. Click . This opens the Formula window.

    2. 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#]

    3. Save the changes.

  3. 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

  1. 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.

  2. Fill out the element properties.

    Property

    Property value

    Title

    Run the AI Skill

  3. 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;
  4. Save the changes.

  5. 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

  1. Add an auto-generated page.

    1. 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.

    2. 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.

  2. 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:

    1. Go to the Page Items block.

    2. Click and select a parameter of the needed type.

    3. 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 parameterProcess parameters tab → Outcome of the Creatio AI workSelect. 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 parametersProcess parameters tab → Status of the Creatio AI executionSelect. 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 parametersProcess 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 format

      Text field

      Title

      Error message (inputText parameter)

      Code

      InputTextParameterErrorMessage

      Value

      Click Process parametersProcess 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

  1. Open the Process library section. To do this, click ProcessesProcess library.
  2. Select the "Summarize contact information" business process in the section list.
  3. 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

  1. Open the Customer 360 app in the No-Code Designer.

  2. Open the Contacts form page.

  3. Add a button.

    For this example, add the button that calls the "Summarize contact information" business process.

    To do this:

    1. Add a Button type component to the toolbar of the Freedom UI Designer.

    2. 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

  4. Save the changes.

View the result

  1. Open the Contacts section.
  2. Open a contact that has an arbitrary name. For example, "Alice Phillips."
  3. 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

// 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;

Resources

Package with example implementation