【问题标题】:How to call method using action.submit in adaptive card Bot application如何在自适应卡片 Bot 应用程序中使用 action.submit 调用方法
【发布时间】:2019-03-05 03:38:22
【问题描述】:

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

【问题讨论】:

  • 这是非常非描述性的。您应该添加通过 Adaptivecards.io 设计器创建的 json。我不确定问题是什么?
  • 您使用的是 C# 还是 JavaScript?
  • @Kyle Delaney 我正在使用 C#
  • Micromuncher 的回答可以接受吗?

标签: botframework cortana adaptive-cards cortana-intelligence


【解决方案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 在返回自适应卡片结果的方式上略有不同。其他频道将为消息附加一个值,因此如果您想支持多个频道...

 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"
  }
},

【讨论】:

    猜你喜欢
    • 2018-11-10
    • 1970-01-01
    • 2019-08-18
    • 2020-12-09
    • 1970-01-01
    • 2022-01-08
    • 2019-04-20
    • 1970-01-01
    • 2018-11-09
    相关资源
    最近更新 更多