Forum Discussion
How do I allow a user to trigger a task module from an adaptive card in the compose area?
- Jan 23, 2023
BazVanDenDungen -We have tried the below sample to achieve this-
Added one button and in value section added deep link. When we click on compose area button it will open the task module.private MessagingExtensionActionResponse CreateCardCommand(ITurnContext<IInvokeActivity> turnContext, MessagingExtensionAction action) { // The user has chosen to create a card by choosing the 'Create Card' context menu command. var createCardData = ((JObject)action.Data).ToObject<CardResponse>(); var card = new HeroCard { Title = createCardData.Title, Subtitle = createCardData.Subtitle, Text =createCardData.Text, Buttons = new List<CardAction> { new CardAction(ActionTypes.OpenUrl, "DeepLink", value: "https://teams.microsoft.com/l/task/XXXXX-bbcd-4a30-9092-3c89XXXXXXX?url=https://XXXX-118-185-XXX-XXX.ngrok.io/customform.html&height=430&width=510&title=CustomForm&completionBotId=734601fc-bbcd-4a30-9092-3c89fxxxxxxx") } }; var attachments = new List<MessagingExtensionAttachment>(); attachments.Add(new MessagingExtensionAttachment { Content = card, ContentType = HeroCard.ContentType, Preview = card.ToAttachment(), }); return new MessagingExtensionActionResponse { ComposeExtension = new MessagingExtensionResult { AttachmentLayout = "list", Type = "result", Attachments = attachments, }, }; }
Video Link- https://youtu.be/ZGYDamLZhjI
We are referring the below sample-
Microsoft-Teams-Samples/TeamsMessagingExtensionsActionBot.cs at 8b5877c6d357e7fe5a261561f6521625312e0f41 · OfficeDev/Microsoft-Teams-Samples (github.com)
Sayali-MSFT yes, while the card is in the compose area OR within the similar view from the command bar when you select it after doing the search.
I have tried both with a Deeplink button & link as well as an AdaptiveSubmitAction from the C# AdaptiveCards sdk to trigger the action.
Neither could be triggered until after the user posted the card in a chat/reply to the channel which does not fit in with our intended use-case.
BazVanDenDungen -We have tried the below sample to achieve this-
Added one button and in value section added deep link. When we click on compose area button it will open the task module.
private MessagingExtensionActionResponse CreateCardCommand(ITurnContext<IInvokeActivity> turnContext, MessagingExtensionAction action)
{
// The user has chosen to create a card by choosing the 'Create Card' context menu command.
var createCardData = ((JObject)action.Data).ToObject<CardResponse>();
var card = new HeroCard
{
Title = createCardData.Title,
Subtitle = createCardData.Subtitle,
Text =createCardData.Text,
Buttons = new List<CardAction> { new CardAction(ActionTypes.OpenUrl, "DeepLink", value: "https://teams.microsoft.com/l/task/XXXXX-bbcd-4a30-9092-3c89XXXXXXX?url=https://XXXX-118-185-XXX-XXX.ngrok.io/customform.html&height=430&width=510&title=CustomForm&completionBotId=734601fc-bbcd-4a30-9092-3c89fxxxxxxx") }
};
var attachments = new List<MessagingExtensionAttachment>();
attachments.Add(new MessagingExtensionAttachment
{
Content = card,
ContentType = HeroCard.ContentType,
Preview = card.ToAttachment(),
});
return new MessagingExtensionActionResponse
{
ComposeExtension = new MessagingExtensionResult
{
AttachmentLayout = "list",
Type = "result",
Attachments = attachments,
},
};
}
Video Link- https://youtu.be/ZGYDamLZhjI
We are referring the below sample-
Microsoft-Teams-Samples/TeamsMessagingExtensionsActionBot.cs at 8b5877c6d357e7fe5a261561f6521625312e0f41 · OfficeDev/Microsoft-Teams-Samples (github.com)