Microsoft Tech Community Live:  Microsoft Teams Edition
November 09, 2021, 08:00 AM - 12:00 PM (PST)

Manage a long-running operation How-To

%3CLINGO-SUB%20id%3D%22lingo-sub-2101233%22%20slang%3D%22en-US%22%3EManage%20a%20long-running%20operation%20How-To%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2101233%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20been%20working%20through%20the%20%22%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fbot-service%2Fbot-builder-howto-long-operations-guidance%3Fview%3Dazure-bot-service-4.0%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EManage%20a%20long-running%20operation%3C%2FA%3E%22%20How-To%20but%20have%20hit%20a%20brick%20wall.%26nbsp%3B%20I%20strongly%20suspect%20this%20is%20because%20I%20am%20being%20a%20bit%20thick%20and%20missing%20something%20obvious%2C%20however%20at%20the%20end%20of%20the%20instructions%20it%20simply%20says%20%22%3CSPAN%3EStart%20the%20Emulator%2C%20connect%20to%20your%20bot%2C%20and%20send%20messages%20as%20shown%20below.%22%2C%20but%20it%20is%20not%20clear%20to%20me%20exactly%20what%20this%20means.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EThe%20messages%20it%20mentions%20start%20with%20a%20%22Please%20select%20a%20long%20test%20operation%20option%22%20adaptive%20card%2C%20however%20this%20is%20produced%20by%20the%20bot%20in%20response%20to%20a%20Event%20Activity.%26nbsp%3B%20How%20do%20I%20produce%20this%20activity%20in%20the%20emulator%3F%26nbsp%3B%20Am%20I%20meant%20to%20be%20interacting%20with%20the%20bot%20using%20another%20tool%3F%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EAny%20ideas%3F%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2101233%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBot%20Framework%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2102340%22%20slang%3D%22en-US%22%3ERe%3A%20Manage%20a%20long-running%20operation%20How-To%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2102340%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20one%20solution%2C%20but%20I%20don't%20know%20if%20it%20is%20the%20correct%20approach%3A%20if%20I%20add%20an%20override%20of%20OnMessageActivityAsync()%2C%20I%20can%20then%20trigger%20the%20dialog%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3Eprotected%20override%20async%20Task%20OnMessageActivityAsync(ITurnContext%3CIMESSAGEACTIVITY%3E%20turnContext%2C%20CancellationToken%20cancellationToken)%0A%7B%0ALogger.LogInformation(%22Running%20dialog%20with%20Message%20Activity.%22)%3B%0A%0A%2F%2F%20Run%20the%20Dialog%20with%20the%20new%20message%20Activity.%0Aawait%20Dialog.RunAsync(turnContext%2C%20ConversationState.CreateProperty%3CDIALOGSTATE%3E(nameof(DialogState))%2C%20cancellationToken)%3B%0A%7D%3C%2FDIALOGSTATE%3E%3C%2FIMESSAGEACTIVITY%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20guessing%20this%20wasn't%20the%20solution%20intended%20by%20the%20author%20of%20the%20How-To%2C%20since%20they%20don't%20include%20that%20override%20in%20the%20example%20code%2C%20but%20at%20least%20it%20moves%20me%20forward%20for%20now...%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I have been working through the "Manage a long-running operation" How-To but have hit a brick wall.  I strongly suspect this is because I am being a bit thick and missing something obvious, however at the end of the instructions it simply says "Start the Emulator, connect to your bot, and send messages as shown below.", but it is not clear to me exactly what this means.

 

The messages it mentions start with a "Please select a long test operation option" adaptive card, however this is produced by the bot in response to a Event Activity.  How do I produce this activity in the emulator?  Am I meant to be interacting with the bot using another tool? 

 

Any ideas?

1 Reply

I have one solution, but I don't know if it is the correct approach: if I add an override of OnMessageActivityAsync(), I can then trigger the dialog:

 

protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
Logger.LogInformation("Running dialog with Message Activity.");

// Run the Dialog with the new message Activity.
await Dialog.RunAsync(turnContext, ConversationState.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken);
}

 

I'm guessing this wasn't the solution intended by the author of the How-To, since they don't include that override in the example code, but at least it moves me forward for now...