0 votes
in Microsoft Bot Framework by

What is the IDialogStack.Forward method in the Bot Framework SDK for .NET?

1 Answer

0 votes
by

The primary purpose of IDialogStack.Forward is to reuse an existing child dialog that is often "reactive", where the child dialog (in IDialog.StartAsync) waits for an object T with some ResumeAfter handler. In particular, if you have a child dialog that waits for an IMessageActivity T, you can forward the incoming IMessageActivity (already received by some parent dialog) by using the IDialogStack.Forward method. For example, to forward an incoming IMessageActivity to a LuisDialog, call IDialogStack.Forward to push the LuisDialog onto the dialog stack, run the code in LuisDialog.StartAsync until it schedules a wait for the next message, and then immediately satisfy that wait with the forwarded IMessageActivity. T is usually an IMessageActivity, since IDialog.StartAsync is typically constructed to wait for that type of activity. You might use IDialogStack.Forward to a LuisDialog as a mechanism to intercept messages from the user for some processing before forwarding the message to an existing LuisDialog. Alternatively, you can also use DispatchDialog with ContinueToNextGroup for that purpose.

You would expect to find the forwarded item in the first ResumeAfter handler (e.g. LuisDialog.MessageReceived) that is scheduled by StartAsync.

Related questions

0 votes
asked Dec 18, 2021 in Microsoft Bot Framework by rajeshsharma
0 votes
asked Mar 5, 2020 in C Sharp by JackTerrance
...