Azure AI Language – Sentiment Analysis in Optimizely CMS

In the following article, I showcase how sentiment analysis, which is part of the Azure AI Language service, can be used to detect the sentiment of content being published within Optimizely CMS.

Sentiment analysis is the process of analysing digital content to determine its tone, whether positive, negative, or neutral. The sentiment analysis feature uses cloud-based machine learning and AI algorithms to help create advanced applications for written language. You can find out more information about Sentiment Analysis here.

One use case of implementing sentiment analysis within Optimizely CMS is to assist content editors in; tailoring their targeted marketing communications, or refining the tone and language of content on webpages.

This feature can be implemented by downloading the “Patel.AzureAILanguage.Optimizely” NuGet package. You can get this package from the Optimizely NuGet Feed or the NuGet Feed.

After obtaining the NuGet Package and completing the required setup , the user needs to add a boolean property with the [TextAnalyticsAllowed] attribute to the Start Page Content Type to activate this functionality. This is detailed in the following link: TextAnalyticsAllowed Documentation.

The next step is to create one or multiple string properties with a [SentimentAnalysis] attribute, suitable for addition to any Optimizely CMS Content type that inherits from IContent. Additional details are available via the following link: SentimentAnalysis Documentation.

When these properties have been added, Sentiment Analysis can be performed when publishing content in the CMS. Below is the response from the API after carrying out sentiment analysis on multiple string properties.

Response from the API via the Console

Analyse Sentiment of multiple page properties operation has completed
Sentiment Analysis done for 8 page properties
Sentiment Result: Mixed
Sentiment Result: Negative
Sentiment Result: Mixed
Sentiment Result: Neutral
Sentiment Result: Neutral
Sentiment Result: Neutral
Sentiment Result: Negative
Sentiment Result: Neutral

If mixed or negative sentiment is detected in any of the page properties, an error message displaying the count of these sentiments will be presented on the CMS screen. This notification will inform the user of the detected sentiments.