Integration

This section describes the necessary steps to integrate with Google Cloud Natural Language API. It includes an extension of the domain model, integration of Scripts, Actions and Triggers, as well as creation of an External page component (detailed in the Cloud development).

The following approach allows to create a portable and flexible solution, e.g. if needed, it can be easily disabled on executing the import.

Schema extension

A new entity definition M.Content.TextAnalysis needs to be introduced with a JSON Content.TextAnalysis.Value property. The M.Content definition is to be extended with a new ContentToTextAnalysis parent-to-child relation to M.Content.TextAnalysis entity definition of OneToOne cardinality. Allow navigation should be set to true.

Content changes

In order to update text analysis results, it is necessary to track content changes and trigger the analysis each time.

  • Script:

    Introduce a new script of type Action, where a check of an M.Content.TextAnalysis entity is performed. If any properties, that belong to member groups of Content content group, have been updated, a corresponding key will be added to the PropertyBag.

    An example of such a script can be downloaded here. Don't forget to enable it after creation.

  • Action:

    Create a new Action of type Action script linked to the script predefined above.

  • Trigger:

    Add a new Trigger with the Entity modification objective and In Process execution type. The trigger's conditions should contain an M.Content entity definition. The action described above is to be selected as a pre-commit action.

Text analysis

  • Script:

    To perform text analysis itself, create a script of type Action: a file with an example can be downloaded via the link, it covers authentication, fetching all Content properties of an entity, sending a request and saving the data from a response to an M.Content.TextAnalysis entity.

    Note

    For authorization, the _authSettings value should be replaced with the corresponding settings from the file with a key obtained during the account setup.

  • Action:

    Add a new action of type Action script and linked to the script.

  • Trigger:

    Introduce a new Trigger with the Entity modification objective and In Background execution type. The trigger's conditions should contain an M.Content entity definition. The action described above is to be selected as a post-commit action.

Auto-tagging

It's possible to create/link existing tags automatically based on the response from Google Cloud Natural Language API.

  • Script:

    In order to enable auto-tagging, create a script of type Action, an example can be downloaded here.

  • Action:

    Add a new action of type Action script and linked to the script.

  • Trigger:

    Add a new Trigger with the Entity modification and Entity creation objective and In Background execution type. The trigger's conditions should contain an M.Content.TextAnalysis entity definition together with Content.TextAnalysis.Value property and value has changed. The action described above is to be selected as a post-commit action.

UI configuration

In order to configure the UI, create a new External component. There are some examples of configuration, code and template.

Do you have some feedback for us?

If you have suggestions for improving this article,