Since you mentioned you used Teams Toolkit C#, I assume you are using Teams Toolkit for Visual Studio.
Current Teams Toolkit and its SDK do not have built-in support for Adaptive Cards action handling. So you need to directly use Bot Framework SDK to write your own ActivityHandler
to handle the card actions.
public class TeamsBot : ActivityHandler
{
protected override async Task<InvokeResponse> OnInvokeActivityAsync(ITurnContext<IInvokeActivity> turnContext, CancellationToken cancellationToken)
{
// Handle card action
if (turnContext.Activity.Name == "adaptiveCard/action")
{
// Handle your action response
var cardJson = await File.ReadAllTextAsync("Resources/ActionResponseCard.json", cancellationToken).ConfigureAwait(false);
var response = JObject.Parse(cardJson);
var adaptiveCardResponse = new AdaptiveCardInvokeResponse()
{
StatusCode = 200,
Type = "application/vnd.microsoft.card.adaptive",
Value = response
};
return CreateInvokeResponse(adaptiveCardResponse);
}
return CreateInvokeResponse(null);
}
}
You also need to use Action.Execute
instead of Action.Submit
which is the newer Universal Actions for Adaptive Cards. It is a unified action model across platforms.
Also see this GitHub issue to learn more.
You can checkout this more complete example in teams samples repo.