Created
December 18, 2019 15:00
-
-
Save jcabot/c4f7be8dc989a7e87cb46f3df931abaf to your computer and use it in GitHub Desktop.
Excerpt showing how to transfer the control of the communication from a chatbot to a human
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
on intent Default_Fallback_Intent from ReactPlatform do | |
val reactChannel = context.get("chat").get("channel") as String | |
var reactSlackMap = session.get("react-slack-map") as com.google.common.collect.BiMap<String, String> | |
if(reactSlackMap === null) { | |
reactSlackMap = com.google.common.collect.HashBiMap.<String, String>create | |
session.put("react-slack-map", reactSlackMap) | |
} | |
val storedSlackTs = reactSlackMap.get(reactChannel) | |
if(storedSlackTs === null) { | |
ReactPlatform.Reply("Sorry I didn't get it, I forward your request to the closest human being") | |
val slackTs = SlackPlatform.PostMessage("[" + context.get("chat").get("username") + "] " + intent.matchedInput, config.get("slack.channel") as String) as String | |
reactSlackMap.put(reactChannel, slackTs) | |
SlackPlatform.PostMessage("_Replies in this thread will be forwarded to the user_", config.get("slack.channel") as String, slackTs) | |
} else { | |
SlackPlatform.PostMessage("[" + context.get("chat").get("username") + "] " + intent.matchedInput, config.get("slack.channel") as String, storedSlackTs) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment