Chaining functions in dialog tree

Hello guys, I am building an assistant to help students learn for their exams (like vocabulary and definitions). At a current “refactoring” I ran into an issue where the text is not properly spoken by snips. This is the (simplified) code:

if (status.activeExercise()) {
    continueExercise(msg, flow, status);
} else {
    selectNewExercise(msg, flow, status);
}

function selectNewExercise(msg, flow, status) {
    flow.continue("Baesm:NoIntent", (msg, flow) => {
        selectDifferentExercise(msg, flow, status);
    })
    flow.continue("Baesm:YesIntent", (msg, flow) => {
        selectSomeExercise(msg, flow, status);
    })
    return ("You have started a new exercise, do you want to do someExercise?");
}

The sentence in the return statement isnt read by snips. Is there a small fix for this I am missing? Everything else works, just not the speaking.

Hi @baesmp,

I cannot tell for sure without reading the rest of the code, but from a quick glance I’m wondering if you are not forgetting some return statements.

// I don't know what is above this piece of code, but…
if (status.activeExercise()) {
    // Maybe you should "return continueExercise…" here?
    continueExercise(msg, flow, status);
} else {
    // And "return selectNewExercise…" here?
    selectNewExercise(msg, flow, status);
}
1 Like

Thanks, thats exactly the small fix I was looking for! Overlooked it, now it works as intended. Solved!

1 Like