SOLVED

Adaptive Card button should return "MessagingExtensionActionResponse"

%3CLINGO-SUB%20id%3D%22lingo-sub-2711269%22%20slang%3D%22en-US%22%3EAdaptive%20Card%20button%20should%20return%20%22MessagingExtensionActionResponse%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2711269%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOur%20application%20used%20to%20send%20notification%20to%20MS%20Teams%20users%20via%20bot.%20The%20application%20has%20been%20developed%20through%20C%23.%20We%20have%20created%20a%20button%20with%20the%20below%20code.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EActions%20%3D%3CBR%20%2F%3E%7B%3CBR%20%2F%3Enew%20AdaptiveSubmitAction()%3CBR%20%2F%3E%7B%3CBR%20%2F%3EType%20%3D%20AdaptiveSubmitAction.TypeName%2C%3CBR%20%2F%3ETitle%20%3D%20%22Click%20Here%22%2C%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3E%7D%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBy%20default%2C%20it%20invoked%20OnMessageActivityAsync().%20Later%20we%20have%20added%20below%20piece%20of%20code%20in%20the%20button%20property.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EData%20%3D%20new%20TaskModuleDetail%3CSTRING%3E()%20%7B%20Data%20%3D%20%22SignIn%22%2C%20CommandId%20%3D%20%22SignIn%22%20%7D%2C%3C%2FSTRING%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20class%20file%20of%20TaskModuleDetail%2C%20we%20have%20defined%20the%20Type%20as%20below.%3C%2FP%3E%3CP%3Epublic%20object%20Type%20%7B%20get%3B%20set%3B%20%7D%20%3D%20JsonConvert.DeserializeObject(%22%7B%5C%22type%5C%22%3A%20%5C%22task%2Ffetch%5C%22%20%7D%22)%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHence%20it%20is%20redirecting%20to%26nbsp%3BOnTeamsTaskModuleFetchAsync().%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20am%20expecting%20the%20click%20event%20of%20button%20should%20hit%26nbsp%3BOnTeamsMessagingExtensionFetchTaskAsync()%20which%20returns%26nbsp%3BMessagingExtensionActionResponse%20as%20i%20need%20to%20do%20launch%20an%20URL%20and%20perform%20authentication.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20someone%20help%20me%20to%20fix%20it%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2711269%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2716873%22%20slang%3D%22en-US%22%3ERe%3A%20Adaptive%20Card%20button%20should%20return%20%22MessagingExtensionActionResponse%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2716873%22%20slang%3D%22en-US%22%3EHi%2C%20I%20don't%20think%20you%20can%20can%20trigger%20OnTeamsMessagingExtensionFetchTaskAsync()%20on%20submit%20of%20adaptive%20card%20button.%20This%20method%20is%20invoked%20when%20we%20try%20to%20trigger%20messaging%20extension.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fmicrosoft.bot.builder.teams.teamsactivityhandler.onteamsmessagingextensionfetchtaskasync%3Fview%3Dbotbuilder-dotnet-stableMessaging%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fmicrosoft.bot.builder.teams.teamsactivityhandler.onteamsmessagingextensionfetchtaskasync%3Fview%3Dbotbuilder-dotnet-stableMessaging%3C%2FA%3E%20extension%20can%20only%20be%20triggered%20from%20compose%20box%2C%20search%20bar%20or%20message%20actions.%20You%20can%20refer%20below%20document.%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fplatform%2Fmessaging-extensions%2Fwhat-are-messaging-extensions%23%3A~%3Atext%3DThe%2520invoke%2520locations%2520are%2520compose%2Cthe%2520next%2520interaction%2520to%2520enable%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoftteams%2Fplatform%2Fmessaging-extensions%2Fwhat-are-messaging-extensions%23%3A~%3Atext%3DThe%2520invoke%2520locations%2520are%2520compose%2Cthe%2520next%2520interaction%2520to%2520enable%3C%2FA%3E.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi All,

 

Our application used to send notification to MS Teams users via bot. The application has been developed through C#. We have created a button with the below code.

 

Actions =
{
new AdaptiveSubmitAction()
{
Type = AdaptiveSubmitAction.TypeName,
Title = "Click Here",
},
},

 

By default, it invoked OnMessageActivityAsync(). Later we have added below piece of code in the button property.

 

Data = new TaskModuleDetail<string>() { Data = "SignIn", CommandId = "SignIn" },

 

In the class file of TaskModuleDetail, we have defined the Type as below.

public object Type { get; set; } = JsonConvert.DeserializeObject("{\"type\": \"task/fetch\" }");

 

Hence it is redirecting to OnTeamsTaskModuleFetchAsync().

 

But am expecting the click event of button should hit OnTeamsMessagingExtensionFetchTaskAsync() which returns MessagingExtensionActionResponse as i need to do launch an URL and perform authentication. 

 

Could someone help me to fix it?

1 Reply
best response confirmed by maheshkumargunasekaran (Occasional Contributor)
Solution

Hi, I don't think you can can trigger OnTeamsMessagingExtensionFetchTaskAsync() on submit of adaptive card button. This method is invoked when we try to trigger messaging extension. https://docs.microsoft.com/en-us/dotnet/api/microsoft.bot.builder.teams.teamsactivityhandler.onteams...

Messaging extension can only be triggered from compose box, search bar or message actions. You can refer below document.
https://docs.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/what-are-messaging-ext....

Thanks