Skip to content

Instantly share code, notes, and snippets.

@jcabot
Created December 18, 2019 15:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jcabot/e3278a70dbea183f772116ea0426eb07 to your computer and use it in GitHub Desktop.
live chat to chatbot transfer communication
on intent Default_Fallback_Intent from SlackPlatform do
val reactSlackMap = session.get("react-slack-map") as com.google.common.collect.BiMap<String, String>
if(reactSlackMap !== null) {
val slackTs = context.get("slack").get("threadTs") as String
val reactChannel = reactSlackMap.inverse.get(slackTs)
if(reactChannel === null) {
if(slackTs.empty) {
/*
* No threadTs means we are in the top-level conversation
*/
SlackPlatform.Reply("You cannot reply in the top-level conversation, please use the dedicated threads")
} else {
SlackPlatform.Reply("_Sorry, I cannot forward your message, the client may have closed the session_")
}
} else {
ReactPlatform.PostMessage("[Real Human " + context.get("chat").get("username") + "] " + intent.matchedInput, reactChannel)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment