Skip to content

Instantly share code, notes, and snippets.

@jazzedge
Created July 8, 2017 13:21
Show Gist options
  • Save jazzedge/df3f81d58467e9a8c2337e6629ad97e9 to your computer and use it in GitHub Desktop.
Save jazzedge/df3f81d58467e9a8c2337e6629ad97e9 to your computer and use it in GitHub Desktop.
Bot check if dialog already active
// https://github.com/Microsoft/BotBuilder/blob/master/Node/examples/basics-help/apps.js
function switchTasks(session, args, next, alreadyActiveMessage) {
// Check to see if we're already active.
// - We're assuming that we're being called from a triggerAction() some
// args.action is the fully qualified dialog ID.
var stack = session.dialogStack();
if (builder.Session.findDialogStackEntry(stack, args.action) >= 0) {
session.send(alreadyActiveMessage);
} else {
// Clear stack and switch tasks
session.clearDialogStack();
next();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment