在代码中,确保已经正确处理了SUBMIT ACTION事件。例如,在Bot Framework中,使用了适当的逻辑来触发相应的方法。
// 处理 Adaptive Card 的 submit action
async function handleCardSubmitAction(context) {
    const value = context.activity.value;
    // 确认提交 action 的 value 中包含需要的信息,如 "action" 和 "data"
    if (value.action === 'submit' && value.data) {
        // 处理提交的数据
        const result = await processSubmittedData(value.data);
        // 回复用户
        await context.sendActivity(`已处理您的请求,结果为:${result}`);
    }
}
// 在 bot.js 中可以这样使用
adapter.processActivity(async (context) => {
    if (context.activity.type === ActivityTypes.Message) {
        // 处理文本消息
    } else if (context.activity.type === ActivityTypes.Invoke) {
        // 处理 Invoke 活动(如 Adaptive Card 的 submit action)
        await handleCardSubmitAction(context);
    }
});
在使用Adaptive Card中的submit action时,需要确保已经正确设置了“msteams”命名空间。这个命名空间允许我们在Adaptive Card中使用特定的属性。
在Bot Framework中,"msteams"命名空间包含了一些属性,如MessageBack或Invoke,使得我们可以使用一些命令来向机器人发送消息。
确保你的Adaptive Card中具有正确的命名空间:
{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.0",
  "body": [
    {
      "type": "Input.Text",
      "id": "username",
      "placeholder": "Username"
    },
    {
      "type": "Input.Text",
      "id": "password",
      "placeholder": "Password",
      "style": "password"
    }
  ],
  "actions": [
    {
      "type": "Action.Submit",
      "title": "Log in",
      "data": {
        "action": "submit",
        "module": "auth",
        "data": {
          "username": "{{username.value}}",
          "password": "{{password.value}}"
        }
      },
      "msteams":