Skip to content

Instantly share code, notes, and snippets.

@mgv99
Last active March 16, 2021 12:09
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 mgv99/69952e197b959e8fd509b6f387eb23c9 to your computer and use it in GitHub Desktop.
Save mgv99/69952e197b959e8fd509b6f387eb23c9 to your computer and use it in GitHub Desktop.
Example chatbot state definition
replyOpinion
.body(context -> {
PerspectiveApiScore score =
(PerspectiveApiScore)context.getIntent().getNlpData().get("nlp.perspectiveapi");
Double toxicity = score.getToxicityScore();
if (!toxicity.equals(PerspectiveApiScore.DEFAULT_SCORE) && toxicity > 0.7) {
reactPlatform.reply(context, "That comment was inappropriate...");
}
else {
reactPlatform.reply(context, "Thank you for your opinion!");
}
})
.next()
.moveTo(awaitingInput);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment