Manipulating waterfall steps Botframework v4

To be honest I’m not even sure that this is strictly supported or that it is even a good idea, but as a point of interest you can manipulate the waterfall steps in v4. E.g. The standard flow is; step 1 -> step 2 -> step 3 -> step n. If your code realises that the user should skip a step then it can invoke the ‘next’ function;

async (dc, args, next) =>
{
    if (someCondition)
    {
        await next(args);
        return;
    }
}

That’s pretty easy. The difficult question, and one that I’m not even sure is (or should be) a valid one, how do you go back a step? Well, it is possible but it’s messy and you can’t get back to the initial step (although that is just starting again). You can go back a step by manipulating the dialog state;

// at step n
async (dc, args, next) =>
{
    if (someCondition)
    {
        var targetStep = 1;
        dc.ActiveDialog.Step = targetStep - 1;
        await Step1Prompt();
        return;
    }
}

I don’t recommend this approach, it’s ugly, but you know…possible.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s