2
votes

I am using Bot framewokV4 and I want to return the adaptive card to Task module in Teams.

I am using Adaptive card with submit value as "data":{"msteams":{"type":"task/fetch"}}" for Task module popup.

How can I return the basic adaptive card to task module from public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) method.

I can return by using protected override async Task<TaskModuleResponse> OnTeamsTaskModuleFetchAsync(ITurnContext<IInvokeActivity> turnContext, TaskModuleRequest taskModuleRequest, CancellationToken cancellationToken) method

but this method is not getting triggered when I use the OnturnAsync method.

Please help, Thanks.

1

1 Answers

3
votes

You should have another look at How bots work, especially "The activity processing stack" and "Bot logic" sections. Basically, there's a sequence of how the event handlers work - OnTurnAsync will get called FIRST in this chain. If you fully handle the event inside your own OnTurnAsync, then the chain will stop processing there. In this particular case, the base OnTurnAsync isn't getting called, and this is the one that -would- have called OnTeamsTaskModuleFetchAsync. Have a look at the source code for the TeamsActivityHandler's OnTurnAsync, which in your clearly case isn't getting called.

Basically, you should either:

1) NOT use your own OnTurnAsync if you don't need to have your own OR 2) If you DO need to implement your OnTurnAsync (like if you're doing some things inside there) then be sure to call base.OnTurnAsync from inside your own OnTurnAsync for any cases you don't handle yourself.

Of course, all of this is assuming you're properly inheriting from TeamsActivityHandler, not just ActivityHandler, otherwise all of the Teams-related stuff won't get loaded.