Sentiment analysis is a feature that analyzes messages during a conversation between a human agent and an end-user to determine emotional intent. You can enable it during conversation profile creation or editing. If you are editing an existing conversation profile, you will only see the effects in conversations after the conversation profile updates. You also have the option to enable sentiment analysis when you create a conversation profile using the Agent Assist console.
- Set
enableSentimentAnalysistotrueinMessageAnalysisConfig. - Send a
createConversationrequest using aConversationProfilewith this feature enabled. - Sentiment results are returned in
AnalyzeContentResponse.message.sentimentAnalysis. - If you have enabled Cloud Pub/Sub integration
in Agent Assist, sentiment result will also appear in the
NewMessagePayload.
Interpret sentiment analysis results
Sentiment is represented by score and magnitude values, metrics that are
returned in the response. The score of the sentiment ranges between -1.0
(negative) and 1.0 (positive) and corresponds to the overall emotional leaning
of the text. The magnitude value indicates the overall strength of emotion
(both positive and negative) within the given text, between 0.0 and +inf.
For more information about interpreting these metrics, see the
Natural Language sentiment analysis documentation.
The following are two examples of sentiment analysis output from the Natural Language API demo feature. To use the demo to test sentiment analysis on sample text: Paste the text into the text box, click ANALYZE, and then select the Sentiment tab.
Example 1
Text: "I'm not happy."
The returned score is -0.9, and the magnitude is 0.9. This indicates a
very strong negative emotional leaning, with low-to-moderate strength of
emotion.

Example 2
Text: "Google cloud is the cloud service from Google."
The returned values of both score and magnitude is 0, which means that the
text does not show any emotion or strength of feelings.

Example 3
Text: "I'm extremely angry and disappointed for the result. On the other hand, I'm happy to see our team was working very hard and show professional attitude."
Unlike Example 1, this text contains two sentences. The output includes
Entire document metrics as well as metrics for each individual sentence.
Entire document values represent the metrics of both sentences combined, not one
or the other. Each individual sentence is also listed with its corresponding
magnitude and score value.
The returned sentiment score for the entire document is 0, while the
magnitude is 1.6. A score of 0 in a multi-sentence document can mean that
it's truly emotionally neutral, or that positive and negative emotional leanings
at various points in the text canceled each other out. Text with a truly neutral
sentiment will also have a magnitude equal to or close to 0. In this case, the
relatively high magnitude of 1.6 means that the sentiment of the two sentences
is not truly neutral, but mixed (for example angry, disappointed and happy at
various points in the text). Looking at the score values for each sentence,
one is strongly positive (0.8) and the other is strongly negative (-0.8), which
caused the entire document score to average to 0.
