Created
August 18, 2017 10:03
-
-
Save shrutis22/5f7c3cd88e349c03ab82817edc84125f to your computer and use it in GitHub Desktop.
Alerts the Sentiment of the text.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{!REQUIRESCRIPT("/soap/ajax/39.0/connection.js")} | |
{!REQUIRESCRIPT("/soap/ajax/39.0/apex.js")} | |
var resp = sforce.apex.execute( | |
"EinsteinServices", | |
"findSentiment", | |
{ | |
"text" : "{!Task.Description}" | |
} | |
); | |
window[ resp[0].probabilities[0].label ] = resp[0].probabilities[0].probability; | |
window[ resp[0].probabilities[1].label ] = resp[0].probabilities[1].probability; | |
window[ resp[0].probabilities[2].label ] = resp[0].probabilities[2].probability; | |
var result = ""; | |
if( negative > positive && negative > neutral ) { | |
result = "Negative"; | |
} | |
else if( positive > negative && positive > neutral ) { | |
result = "Positive"; | |
} | |
else { | |
result = "Neutral"; | |
} | |
alert( result ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment