如何在自适应卡Bot应用程序中使用action.submit调用方法

问题描述 投票:0回答:1

我正在使用自适应卡。 (Bot Framework SDK v3)我需要在自适应卡中获取值,我还需要在代码中调用一些方法。这是我的自适应cardAdaptive Card

botframework cortana adaptive-cards cortana-intelligence
1个回答
1
投票

我猜一个答案;如果你读过https://docs.microsoft.com/en-us/cortana/skills/adaptive-cards

然后你的问题可能是“好吧,响应是什么样的?”我同意,这在文档中并不清楚。

单击submit.action时,您将在消息有效内容中返回所有ID和值。例如,如果你在这里查看输入示例https://adaptivecards.io/samples/Inputs.html

您点击的响应消息将是此{"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":""}

你的技能应该足够智能,将message.text识别为json,然后使用表单字段中的id来收集值。

请注意,Cortana在HOW中略有不同,返回自适应卡结果。其他渠道会为邮件附加一个值,所以如果你想支持多个渠道......

 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 ... }

另请注意,您也可以将数据添加到可以在有效负载中发送的操作中

{
  "type": "Action.Submit",
  "title": "Submit",
  "data": {
    "id": "1234567890"
  }
},
© www.soinside.com 2019 - 2024. All rights reserved.