Skip to content

Instantly share code, notes, and snippets.

@shrutis22
Created August 18, 2017 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrutis22/5f7c3cd88e349c03ab82817edc84125f to your computer and use it in GitHub Desktop.
Save shrutis22/5f7c3cd88e349c03ab82817edc84125f to your computer and use it in GitHub Desktop.
Alerts the Sentiment of the text.
{!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