How to call method using action.submit in adaptive card Bot application

1.1k Views Asked by At

I am using a adaptive card. (Bot Framework SDK v3) I need to get the values in adaptive card and also i need to call some method in code behind. This is my adaptive cardAdaptive Card.

1

There are 1 best solutions below

0
Micromuncher On

I am going to guess at an answer; if you have read https://learn.microsoft.com/en-us/cortana/skills/adaptive-cards

Then your question might be "well, what does the response look like?" I agree, this is not clear in the documentation.

When you click a submit.action, you will get all the ids and values back in the message payload. For example, if you look at the input example here https://adaptivecards.io/samples/Inputs.html

Your response message to a click will be this {"SimpleVal":"My name","UrlVal":"","EmailVal":"","TelVal":"","MultiLineVal":"","NumVal":"1","DateVal":"2017-09-20","TimeVal":"16:59","CompactSelectVal":"1","SingleSelectVal":"1","MultiSelectVal":"1;3","AcceptsTerms":"on","CommentVal":""}

Your skill should be smart enough to recognize the message.text as json, and then use the id from the form field to glean the value.

Note that Cortana differs slightly in HOW adaptive card results are returned. Other channels will attach a value to the message so if you want to support multiple channels...

 if( session.message.text && session.channel === 'cortana' ) 
  { ... digest the json in the message ... }

 if( session.message.value ) 
  { ... digest the values attached to the message for non-cortana ... }

And also note that you can add data to the action too that could be sent in a payload

{
  "type": "Action.Submit",
  "title": "Submit",
  "data": {
    "id": "1234567890"
  }
},