Work with Universal Actions for Adaptive Cards
Universal Actions for Adaptive Cards provides a way to implement Adaptive Card based scenarios for both, Teams and Outlook. This document covers the following:
- Schema used for Universal Actions for Adaptive Cards
- Refresh model
- Backward compatibility
Quick start guide to leverage Universal Actions for Adaptive Cards in Teams
Replace all instances of
Action.Executeto update an existing scenario on Teams.
refreshclause to your Adaptive Card, if you want to leverage the automatic refresh model or if your scenario requires User Specific Views.
userIdsproperty to identify, which users get automatic updates.
adaptiveCard/actioninvoke requests in your bot.
Use the invoke request's context to respond back with cards that are specifically created for a user.
Whenever your bot returns a new card as a result of processing an
Action.Execute, the response must conform to the response format.
Schema for Universal Actions for Adaptive Cards
Universal Actions for Adaptive Cards is introduced in the Adaptive Cards schema version 1.4. To use Adaptive Card effectively, the
version property of your Adaptive Card must be set to 1.4.
version property to 1.4 makes your Adaptive Card incompatible with older clients of the platforms or applications, such as Outlook and Teams, as they do not support the Universal Actions for Adaptive Cards.
If you set the card version to less than 1.4 and use either or both,
refresh property and
Action.Execute, the following happens:
|Teams||Your card stops working. Card is not refreshed and
For more information on how to support older clients, see backward compatibility.
When authoring Adaptive Cards, replace
Action.Execute. The schema for
Action.Execute is similar to that of
For more information, see Action.Execute schema and properties.
Now, you can use the refresh model to allow Adaptive Cards to update automatically.
To automatically refresh your Adaptive Card, define its
refresh property, which embeds an action of type
Action.Execute and an
For more information, see refresh schema and properties.
User IDs in refresh
The following are the features of UserIds in refresh:
UserIds is an array of user MRI's which is part of the
refreshproperty in Adaptive Cards.
userIdslist property is specified as
userIds: in the refresh section of the card, the card is not automatically refreshed. Instead, a Refresh Card option is displayed to the user in the triple dot menu in web or desktop and in the long press context menu in mobile, that is, Android or iOS to manually refresh the card.
UserIds property is added because channels in Teams can include a large number of members. If all members are viewing the channel at the same time, an unconditional automatic refresh results in many concurrent calls to the bot. To avoid this, the
userIdsproperty must always be included to identify which users must get an automatic refresh with a maximum of 60 (sixty) user MRIs.
For more information on how you can fetch Teams conversation member's user MRIs to add in userIds list in refresh section of Adaptive Card, see fetch roster or user profile.
Sample Teams user MRI is
userIds property is ignored in Outlook, and the
refresh property is always automatically activated. There is no scale issue in Outlook because users view the card at different times.
Next step is to use the
adaptiveCard/action invoke activity to understand what request must be made after
Action.Execute is executed.
adaptiveCard/action invoke activity
Action.Execute is executed in the client, a new type of Invoke activity
adaptiveCard/action is made to your bot.
For more information, see request format and properties for a typical
adaptiveCard/action invoke activity.
Next, you can apply backward compatibility to older clients across different platforms and make your Adaptive Card compatible.
Universal Actions for Adaptive Cards allows you to set properties that enable backward compatibility with older versions of Outlook and Teams.
To ensure backward compatibility of your Adaptive Cards with older versions of Teams, you must include the
fallback property and set its value to
Action.Submit. Also, your bot code must process both
For more information, see backward compatibility on Teams.
|Teams catering bot||Create a simple bot that accepts food order using Adaptive Cards.||View|