Forum Discussion
What is the replacement for OnAdaptiveCardInvokeAsync in TeamsToolkit V5
With the new Teams version breaking my current bot I'm having a look at the new Teams Toolkit V5 and the function I used before was the OnAdaptiveCardInvokeAsync as it gets the verb from the card's button clicks. However now this is not called, what is the replacement for this function?
Hi mattphillips,
OnAdaptiveActionExecuteAsync is a function in TeamsToolkit V5 that is called when a button or other action is clicked on an Adaptive Card. It can be used to replace the OnAdaptiveCardInvokeAsync function in previous versions of TeamsToolkit.
To use OnAdaptiveActionExecuteAsync, you need to add the following code to your bot's App.xaml.cs file:
protected override async Task OnAdaptiveActionExecuteAsync(AdaptiveActionEventArgs e) { // Get the verb from the Adaptive Card action. string verb = e.Action.Verb; // Switch on the verb to determine what action to take. switch (verb) { case "submit": // Submit the form. break; case "cancel": // Cancel the form. break; default: // Do something else. break; } }You can then add a button to your Adaptive Card with the following code:
{ "type": "Action.Submit", "title": "Submit", "verb": "submit" }When the user clicks the button, the OnAdaptiveActionExecuteAsync function will be called and you can then take the appropriate action.
For example, you could use OnAdaptiveActionExecuteAsync to submit a form, send a message, or open another Adaptive Card.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)
1 Reply
- LeonPavesicSilver Contributor
Hi mattphillips,
OnAdaptiveActionExecuteAsync is a function in TeamsToolkit V5 that is called when a button or other action is clicked on an Adaptive Card. It can be used to replace the OnAdaptiveCardInvokeAsync function in previous versions of TeamsToolkit.
To use OnAdaptiveActionExecuteAsync, you need to add the following code to your bot's App.xaml.cs file:
protected override async Task OnAdaptiveActionExecuteAsync(AdaptiveActionEventArgs e) { // Get the verb from the Adaptive Card action. string verb = e.Action.Verb; // Switch on the verb to determine what action to take. switch (verb) { case "submit": // Submit the form. break; case "cancel": // Cancel the form. break; default: // Do something else. break; } }You can then add a button to your Adaptive Card with the following code:
{ "type": "Action.Submit", "title": "Submit", "verb": "submit" }When the user clicks the button, the OnAdaptiveActionExecuteAsync function will be called and you can then take the appropriate action.
For example, you could use OnAdaptiveActionExecuteAsync to submit a form, send a message, or open another Adaptive Card.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)