jazzedge
7/8/2017 - 1:21 PM

Bot check if dialog already active

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();
    }
}