How to use the botbuilder-dialogs.DialogReason.nextCalled function in botbuilder-dialogs

To help you get started, we’ve selected a few botbuilder-dialogs examples, based on popular ways it is used in public projects.

github howdyai / botkit / packages / botkit / src / conversation.ts View on Github external
if (nextCalled) {
                    throw new Error(`ScriptedStepContext.next(): method already called for dialog and step '${ this.id }[${ index }]'.`);
                }

                return await this.resumeDialog(dc, DialogReason.nextCalled, stepResult);
            }
        };

        // did we just start a new thread?
        // if so, run the before stuff.
        if (index === 0) {
            await this.runBefore(step.thread, dc, step);

            // did we just change threads? if so, restart
            if (index !== step.index || thread_name !== step.thread) {
                return await this.runStep(dc, step.index, step.thread, DialogReason.nextCalled); // , step.values);
            }
        }

        // Execute step
        const res = await this.onStep(dc, step);

        return res;
    }
github howdyai / botkit / packages / botkit / src / conversation.ts View on Github external
const thread_name = step.thread;

            // spawn a bot instance so devs can use API or other stuff as necessary
            const bot = await this._controller.spawn(dc);

            // create a convo controller object
            const convo = new BotkitDialogWrapper(dc, step);

            await path.handler.call(this, step.result, convo, bot);

            if (!dc.activeDialog) {
                return false;   
            }
            // did we just change threads? if so, restart this turn
            if (index !== step.index || thread_name !== step.thread) {
                return await this.runStep(dc, step.index, step.thread, DialogReason.nextCalled, null);
            }

            return false;
        }

        switch (path.action) {
        case 'next':
            // noop
            break;
        case 'complete':
            step.values._status = 'completed';
            return await this.end(dc);
        case 'stop':
            step.values._status = 'canceled';
            return await this.end(dc);
        case 'timeout':
github howdyai / botkit / packages / botbuilder-dialogs-botkit-cms / src / index.ts View on Github external
if (nextCalled) {
                        throw new Error(`ScriptedStepContext.next(): method already called for dialog and step '${ this.id }[${ index }]'.`);
                    }

                    return await this.resumeDialog(dc, DialogReason.nextCalled, stepResult);
                }
            };

            // did we just start a new thread?
            // if so, run the before stuff.
            if (index === 0 && previous_thread != thread_name) {
                await this.runBefore(step.thread, dc, step);

                // did we just change threads? if so, restart
                if (index != step.index || thread_name != step.thread) {
                    return await this.runStep(dc, step.index, step.thread, DialogReason.nextCalled, step.values);
                }
            }

            // Execute step
            const res = await this.onStep(dc, step);

            return res;
        } else {

            // End of script so just return to parent
            return await dc.endDialog(result);
        }
    }
github howdyai / botkit / packages / botbuilder-dialogs-botkit-cms / src / index.ts View on Github external
private async gotoThreadAction(thread, dc, step) {
        await this.gotoThread(thread, dc, step);
        // await this.runBefore(step.thread, dc, step);
        return await this.runStep(dc, step.index, step.thread, DialogReason.nextCalled, step.values);
    }
github howdyai / botkit / packages / botbuilder-dialogs-botkit-cms / src / index.ts View on Github external
next: async (stepResult) => {
                    if (nextCalled) {
                        throw new Error(`ScriptedStepContext.next(): method already called for dialog and step '${ this.id }[${ index }]'.`);
                    }

                    return await this.resumeDialog(dc, DialogReason.nextCalled, stepResult);
                }
            };
github howdyai / botkit / packages / botkit / src / conversation.ts View on Github external
next: async (stepResult) => {
                if (nextCalled) {
                    throw new Error(`ScriptedStepContext.next(): method already called for dialog and step '${ this.id }[${ index }]'.`);
                }

                return await this.resumeDialog(dc, DialogReason.nextCalled, stepResult);
            }
        };