Forum Discussion
Jason1395
Apr 11, 2024Copper Contributor
How to use the adaptive metadata
I want to use adaptive metadata store some data in teams bot, and get the data in
handleTeamsTaskModuleFetch() when I click the button in the adaptive card. Is it possible?
If not, can anybody please give an example how to use the adaptive metadata correctly.
- Dinesh-MSFT
Microsoft
Hi Jason1395,
Dialogs with Adaptive Cards work similarly to the HTML or JavaScript case. The major difference is that, because there's no JavaScript when you're using Adaptive Cards, there's no way to call submit(). Instead, Teams takes the
data
object fromAction.Submit
and returns it as the payload of thetask/submit
event.In your adaptive card JSON, include an
Action.Submit
action and place the metadata you want to pass within thedata
property of the action.In your bot's code, implement thehandleTeamsTaskModuleFetch
function. This function will be called when the user interacts with the adaptive card. Within thehandleTeamsTaskModuleFetch
function, you can access the metadata sent from the adaptive card by reading thetaskModuleRequest.data
property. Then use the extracted metadata to populate the task module dialog that you want to present to the user.Ref: Use dialogs in Microsoft Teams bots - Teams | Microsoft Learn
- Jason1395Copper Contributor
Hi Dinesh-MSFT ,
Thanks for your reply.
I know this solution. The problem is that the adaptive card size has a limitation, but the data is very large which I want to store in the adaptive card. Which will raise an error "MessageSizeTooBig" when I create the adaptive card with the large data.
So, I want to try metadata ( https://adaptivecards.io/explorer/Metadata.html ). But I do not know how to use it.
- ray2408Brass Contributor
Dinesh-MSFT any update on this
- Dinesh-MSFT
Microsoft
Hi Jason1395 - Thanks for raising the query.
We will look into it and let you know the updates.