0
votes

I am writing a messaging extension for users to be send adaptive cards. I did created adaptive card from MessagingExtensionResult from query panel and added Tap action to ThumbnailCard for rating, but when I click Action.Submit and rised OnTeamsMessagingExtensionCardButtonClickedAsync event, I can not send a response or update adaptive card for responses. It always show "Unable to reach app. Please try again.".

enter image description here

I can get data but can't update adaptive card for user to see actions for their selections. Is there any way OnTeamsMessagingExtensionCardButtonClickedAsync to update rised adaptive card or send an update to channel.

To be remember, my app is not a bot so its not fully capable of doing bot events or actions.

1
Hi @Ali Hidim, Thank You for reaching us! Sorry for the delayed response! We are working on it practically and checking with our Engineering Team so will update you soon. - Rama-MSFT
Hi, @Rama-MSFT thank you. I did changed my like buttons for “task/fetch” (with msteams attribute) and opening a task window for details but after this action buttons stays as same and look like nothing happens :). I’m looking for your response thanks again :). - Ali Hidim
Hi @Ali Hidim, we have tested from our end, but to know where exactly the error is, we request you share us the manifest. - Rama-MSFT
Hi @Rama-MSFT you can see my manifest in pastebin.com/7pP900uY - Ali Hidim

1 Answers

0
votes

In your card button please add action type as Invoke

    var createCardData = ((JObject)action.Data).ToObject<CreateCardData>();

 var card = new HeroCard
{
Title = createCardData.Title,
Subtitle = createCardData.Subtitle,
Text = createCardData.Text,
Buttons = new List<CardAction>{new CardAction(){Title = "button1",Type = "invoke",Text = "this message is updated",Value = "this message is updated",} }
};

 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,
},
};

when you click on button in card, it will call OnTeamsMessagingExtensionCardButtonClickedAsync() method. Send adaptive card attachment as a response.

protected override async Task OnTeamsMessagingExtensionCardButtonClickedAsync(ITurnContext<IInvokeActivity> turnContext, JObject obj, CancellationToken cancellationToken)
{
var reply = MessageFactory.Attachment(CreateAdaptiveCardAttachment());
await turnContext.SendActivityAsync(reply, cancellationToken);
}