Skip to content

SentimentAnalysis

Element Name: SentimentAnalysis

Category: Cognitive

Description: An advanced extension module that utilizes Azure's sentiment analysis. It provides sentiment labels (such as "negative," "neutral," and "positive") determined based on the highest confidence score detected by the service, both at the sentence and document level. Additionally, this function provides confidence scores in the range of 0 to 1 for each sentence and document, reflecting positive, neutral, and negative sentiments present in them.

Functionality: Allows understanding and leveraging text data based on the emotions or attitudes expressed in that text. It helps in assessing opinions of products and services, measuring customer satisfaction while interacting with an agent or bot, and personalizing content and recommendations.

Prerequisite:

Create a resource in Azure: Access the Microsoft Azure portal (portal.azure.com) in the "Create Resource" section and locate the "Language Service" resource. For more information, refer to the documentation on how to create this resource Link to Azure Documentation

Configuration Fields for Sentiment Analysis Action (Required)

[Name]: Unique descriptor of the configuration box for the purpose of identifying it in the flow.

[Expression to Evaluate]: A string expression field where the text (within quotes) or entity containing the text to evaluate (without quotes) must be defined.

[Language of Text to Evaluate]: A dropdown list where the language of the text to be evaluated should be selected.

[Entity to Store the Evaluation Result]: A dropdown list where the entity that will store the analysis result in JSON format should be selected. An entity can also be created by pressing the "Create Entity" button.

[Sentiment Analysis Subscription Key]: In this text field, you should define the key of the Azure services, which is a character string that can be obtained from the Azure cognitive services console (from the Azure service created as a prerequisite). This information can be found in the "keys and endpoint" section, as shown in the figure.

[Sentiment Analysis Endpoint]: In this field, you should define the endpoint of the Azure services, which is a URL that can be obtained from the Azure cognitive services console in the "keys and endpoint" section, as shown in the figure.

[Intent to Execute in Case of Error]: A dropdown list where the entity name for error handling should be selected.

Implementation Example

The following example describes the required configuration to detect the sentiment expressed by a customer in a text.

-- Preconditions:

Access to the Azure console to obtain keys and URLs.

-- Input:

[Expression to Evaluate]: 'Hello, I am very angry because my order did not arrive.'

[Language of Text to Evaluate]: es

[Entity to Store the Evaluation Result]: Result_Sentiment

[Sentiment Analysis Subscription Key]: xxxxxxxxxxxxxxxxxxx

[Sentiment Analysis Endpoint]: https://mynewresource.cognitiveservices.azure.com/

-- Result: Result_Sentiment <--

    {
        "ConfidenceScores": {
            "Positive": 0.0,
            "Neutral": 0.0,
            "Negative": 0.99
        },
        "Length": 51,
        "Offset": 0,
        "Opinions": [],
        "Sentiment": "Negative",
        "Text": "Hello, I am very angry because my order did not arrive."
    }