BotFramework-Composer icon indicating copy to clipboard operation
BotFramework-Composer copied to clipboard

Adaptive Card triggered twice on click of button

Open shrutinehra opened this issue 4 years ago • 11 comments

Describe the bug

On click of submit button in adaptive card next action is called twice.

Version

Version: 2.0.0 Electron: 8.2.4 Chrome: 80.0.3987.165 NodeJS:12.13.0 V8: 8.0.426.27-electron.0

Browser

Chrome, Safari

OS

macOS, Windows

To Reproduce

Steps to reproduce the behavior: Have the below adaptive card in bot composer

{
  "type": "AdaptiveCard",
  "body": [
    {
      "type": "TextBlock",
      "size": "Medium",
      "weight": "Bolder",
      "text": "Submit a Referral"
    },
    {
      "type": "TextBlock",
      "text": "Please Confirm the below details.",
      "wrap": true
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "title": "First Name:",
          "value": "${dialog.CandidateFirstName}"
        },
        {
          "title": "Last Name:",
          "value": "${dialog.CandidateLastName}"
        },
        {
          "title": "Email:",
          "value": "${dialog.CandidateEmail}"
        },
        {
          "title": "Job Number(s):",
          "value": "${dialog.JobNumber}"
        }
      ]
    }
  ],
  "actions": [
    {
      "type": "Action.ShowCard",
      "title": "Update",
      "card": {
        "version": "1.3",
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "Input.Text",
            "id": "FirstName",
            "value": "${dialog.CandidateFirstName}"
          },
          {
            "type": "Input.Text",
            "id": "LastName",
            "value": "${dialog.CandidateLastName}"
          },
          {
            "type": "Input.Text",
            "id": "Email",
            "value": "${dialog.CandidateEmail}"
          },
          {
            "type": "Input.Text",
            "id": "JobNumber",
            "value": "${dialog.JobNumber}"
          }
        ],
        "actions": [
          {
            "type": "Action.Submit",
            "title": "OK",
            "associatedInputs": "auto",
            "style": "positive",
            "data": {
              "msteams": {
                "type": "update"
              }
            }
          },
          {
            "type": "Action.Submit",
            "title": "Cancel",
            "data": {
              "msteams": {
                "type": "cancelupdate"
              }
            },
            "associatedInputs": "none"
          }
        ],
        "$schema": ""
      }
    },
    {
      "type": "Action.Submit",
      "title": "Submit",
      "associatedInputs": "auto",
      "data": {
        "msteams": {
          "type": "submit"
        }
      }
    },
    {
      "type": "Action.Submit",
      "title": "Cancel",
      "associatedInputs": "none",
      "data": {
        "msteams": {
          "type": "cancel"
        }
      }
    }
  ],
  "$schema": "",
  "version": "1.4"
}

Expected behavior

Submit button should trigger only once

Screenshots

image

shrutinehra avatar Dec 20 '21 15:12 shrutinehra

I'll take a look and see if I can reproduce.

dmvtech avatar Dec 20 '21 19:12 dmvtech

Hi @shrutinehra I believe the reason that the card is showing again is because there is a max turn count. I can't say for sure without seeing more/all of your bot or dialog. You can set the max turn count to 0 to avoid this.

Additionally; you are prompting for an attachment, but you are not sending any attachment back; correct? you are just submitting the card action.

dmvtech avatar Dec 21 '21 18:12 dmvtech

@dmvtech I tried max turn count to 0 but it's still the same issue. To show the adaptive card I had to use attachment type and choose adaptive card image

shrutinehra avatar Dec 22 '21 17:12 shrutinehra

The activity sent has to be an attachment, but what the user is sending back is not attachment. It's just an activity. Does this reproduce in the local Composer webchat (outside of Teams)? Are you able to share your bot or .dialog?

dmvtech avatar Dec 22 '21 22:12 dmvtech

Hi @shrutinehra Any updates? Are you able to share your bot or dialog?

dmvtech avatar Dec 28 '21 21:12 dmvtech

{ "$kind": "Microsoft.AdaptiveDialog", "$designer": { "id": "Rl4QRQ", "name": "ReferralForm", "description": "" }, "autoEndDialog": true, "defaultResultProperty": "dialog.result", "triggers": [ { "$kind": "Microsoft.OnBeginDialog", "$designer": { "name": "BeginDialog", "description": "", "id": "99oM5c" }, "actions": [ { "$kind": "Microsoft.IfCondition", "$designer": { "id": "l8EAbe" }, "condition": "=empty(dialog.CandidateFirstName)", "actions": [ { "$kind": "Microsoft.TextInput", "$designer": { "id": "rLPYYT" }, "disabled": false, "maxTurnCount": 3, "alwaysPrompt": false, "allowInterruptions": false, "prompt": "${TextInput_Prompt_rLPYYT()}", "unrecognizedPrompt": "", "invalidPrompt": "", "defaultValueResponse": "", "property": "dialog.CandidateFirstName" } ] }, { "$kind": "Microsoft.IfCondition", "$designer": { "id": "0Q2nTQ" }, "condition": "=empty(dialog.CandidateLastName)", "actions": [ { "$kind": "Microsoft.TextInput", "$designer": { "id": "DNBRxz" }, "disabled": false, "maxTurnCount": 3, "alwaysPrompt": false, "allowInterruptions": false, "prompt": "${TextInput_Prompt_DNBRxz()}", "unrecognizedPrompt": "", "invalidPrompt": "", "defaultValueResponse": "", "property": "dialog.CandidateLastName" } ] }, { "$kind": "Microsoft.IfCondition", "$designer": { "id": "5VjWwT" }, "condition": "=empty(dialog.JobNumber)", "actions": [ { "$kind": "Microsoft.TextInput", "$designer": { "id": "Elyi35" }, "disabled": false, "maxTurnCount": 3, "alwaysPrompt": false, "allowInterruptions": false, "prompt": "${TextInput_Prompt_Elyi35()}", "unrecognizedPrompt": "", "invalidPrompt": "", "defaultValueResponse": "", "property": "dialog.JobNumber" } ] }, { "$kind": "Microsoft.IfCondition", "$designer": { "id": "qkd2AA" }, "condition": "=empty(dialog.CandidateEmail) && !isMatch(dialog.CandidateEmail, "\\w+([-+.]\\w+)@\\w+([-.]\\w+)\\.\\w+([-.]\\w+)")", "actions": [ { "$kind": "Microsoft.TextInput", "$designer": { "id": "qnt9t1" }, "disabled": false, "maxTurnCount": 3, "alwaysPrompt": false, "allowInterruptions": false, "prompt": "${TextInput_Prompt_qnt9t1()}", "property": "dialog.CandidateEmail", "validations": [ "isMatch(this.value,"\\w+([-+.]\\w+)@\\w+([-.]\\w+)\\.\\w+([-.]\\w+)")" ], "invalidPrompt": "${TextInput_InvalidPrompt_qnt9t1()}", "unrecognizedPrompt": "${TextInput_UnrecognizedPrompt_qnt9t1()}" } ] }, { "$kind": "Microsoft.IfCondition", "$designer": { "id": "bdXL3q" }, "condition": "= !empty(dialog.CandidateEmail) && !empty(dialog.CandidateFirstName) && !empty(dialog.CandidateLastName) && !empty(dialog.JobNumber)", "elseActions": [ { "$kind": "Microsoft.SendActivity", "$designer": { "id": "tI1tRx" }, "activity": "${SendActivity_tI1tRx()}" }, { "$kind": "Microsoft.EndDialog", "$designer": { "id": "YeMaqi" } } ], "actions": [] }, { "$kind": "Microsoft.SetProperty", "$designer": { "id": "MdhtSo" }, "property": "user.clicked", "value": "='1'" }, { "$kind": "Microsoft.AttachmentInput", "$designer": { "id": "PNYxJ0" }, "disabled": false, "maxTurnCount": 0, "alwaysPrompt": true, "allowInterruptions": false, "prompt": "${AttachmentInput_Prompt_PNYxJ0()}", "unrecognizedPrompt": "", "invalidPrompt": "", "property": "dialog.selectedInputattach" }, { "$kind": "Microsoft.SetProperties", "$designer": { "id": "kNYgtG" }, "assignments": [ { "property": "dialog.activityclicked", "value": "=turn.lastresult.id" }, { "property": "dialog.selectedInput", "value": "=turn.activity.value" }, { "property": "dialog.activity", "value": "=turn.activity" }, { "property": "user.clicked", "value": "'2'" } ] }, { "$kind": "Microsoft.IfCondition", "$designer": { "id": "ozeCq7" }, "condition": "=dialog.selectedInput && !turn.activity.text ", "actions": [ { "$kind": "Microsoft.SwitchCondition", "$designer": { "id": "CJRntu" }, "condition": "dialog.selectedInput.msteams.type", "cases": [ { "value": "cancelupdate", "actions": [ { "$kind": "Microsoft.UpdateActivity", "$designer": { "id": "e8F8u4" }, "activityId": "=dialog.activity.replyToId", "activity": "${UpdateActivity_Activity_e8F8u4()}" }, { "$kind": "Microsoft.ChoiceInput", "$designer": { "id": "oXHHMc" }, "defaultLocale": "en-us", "disabled": false, "maxTurnCount": 3, "alwaysPrompt": false, "allowInterruptions": false, "prompt": "${ChoiceInput_Prompt_oXHHMc()}", "unrecognizedPrompt": "", "invalidPrompt": "", "defaultValueResponse": "", "choiceOptions": { "includeNumbers": true, "inlineOrMore": ", or ", "inlineOr": " or ", "inlineSeparator": ", " }, "property": "dialog.submit", "choices": [ "Yes", "No" ] }, { "$kind": "Microsoft.IfCondition", "$designer": { "id": "tc9OSb" }, "condition": "dialog.submit=='Yes'", "actions": [ { "$kind": "Microsoft.BeginDialog", "$designer": { "id": "el2fIB" }, "activityProcessed": true, "dialog": "ReferralProcessing", "options": { "RefId": "=dialog.JobNumber", "CandidateFirstName": "=dialog.CandidateFirstName", "CandidateLastName": "=dialog.CandidateLastName", "CandidateEmail": "=dialog.CandidateEmail", "EmployeeDetail": "=user.EmployeeDetail" } }, { "$kind": "Microsoft.CancelAllDialogs", "$designer": { "id": "4ciTXL" }, "activityProcessed": true } ], "elseActions": [ { "$kind": "Microsoft.SendActivity", "$designer": { "id": "0XwzpB" }, "activity": "${SendActivity_0XwzpB()}" } ] } ] }, { "value": "cancel", "actions": [ { "$kind": "Microsoft.SendActivity", "$designer": { "id": "PUF74A" }, "activity": "${SendActivity_PUF74A()}" }, { "$kind": "Microsoft.UpdateActivity", "$designer": { "id": "taErFv" }, "activityId": "=dialog.activity.replyToId", "activity": "${UpdateActivity_Activity_taErFv()}" } ] }, { "value": "update", "actions": [ { "$kind": "Microsoft.SetProperties", "$designer": { "id": "a6ToMG" }, "assignments": [ { "property": "dialog.CandidateFirstName", "value": "=dialog.selectedInput.FirstName" }, { "property": "dialog.CandidateLastName", "value": "=dialog.selectedInput.LastName" }, { "property": "dialog.CandidateEmail", "value": "=dialog.selectedInput.Email" }, { "property": "dialog.JobNumber", "value": "=dialog.selectedInput.JobNumber" } ] }, { "$kind": "Microsoft.UpdateActivity", "$designer": { "id": "ZkciZs" }, "activityId": "=dialog.activity.replyToId", "activity": "${UpdateActivity_Activity_ZkciZs()}" }, { "$kind": "Microsoft.BeginDialog", "$designer": { "id": "yoO9PD" }, "activityProcessed": true, "dialog": "ReferralProcessing", "options": { "RefId": "=dialog.JobNumber", "CandidateFirstName": "=dialog.CandidateFirstName", "CandidateLastName": "=dialog.CandidateLastName", "CandidateEmail": "=dialog.CandidateEmail", "EmployeeDetail": "=user.EmployeeDetail" } }, { "$kind": "Microsoft.CancelAllDialogs", "$designer": { "id": "khsYey" }, "activityProcessed": true } ] }, { "value": "submit", "actions": [ { "$kind": "Microsoft.UpdateActivity", "$designer": { "id": "zqgXwW" }, "activityId": "=dialog.activity.replyToId", "activity": "${UpdateActivity_Activity_zqgXwW()}" }, { "$kind": "Microsoft.BeginDialog", "$designer": { "id": "nSubLb" }, "activityProcessed": true, "dialog": "ReferralProcessing", "options": { "RefId": "=dialog.JobNumber", "CandidateFirstName": "=dialog.CandidateFirstName", "CandidateLastName": "=dialog.CandidateLastName", "CandidateEmail": "=dialog.CandidateEmail", "EmployeeDetail": "=user.EmployeeDetail" } }, { "$kind": "Microsoft.DeleteProperties", "$designer": { "id": "Xg6vue" }, "properties": [ "dialog.JobNumber", "dialog.CandidateFirstName", "dialog.CandidateLastName", "dialog.CandidateEmail" ] }, { "$kind": "Microsoft.CancelAllDialogs", "$designer": { "id": "7com2i" }, "activityProcessed": true } ] } ] } ], "elseActions": [ { "$kind": "Microsoft.SendActivity", "$designer": { "id": "Gl7Snt" }, "activity": "${SendActivity_Gl7Snt()}" } ] }, { "$kind": "Microsoft.EndDialog", "$designer": { "id": "mQDsNG" } } ] } ], "generator": "ReferralForm.lg", "recognizer": "ReferralForm.lu.qna", "id": "ReferralForm" }

shrutinehra avatar Dec 29 '21 18:12 shrutinehra

@dmvtech It reproduces in web chat as well..

shrutinehra avatar Dec 29 '21 18:12 shrutinehra

Hi @shrutinehra

Can you try this as the adaptive card and see if that works?:

{
  "type": "AdaptiveCard",
  "body": [
    {
      "type": "TextBlock",
      "size": "Medium",
      "weight": "Bolder",
      "text": "Submit a Referral"
    },
    {
      "type": "TextBlock",
      "text": "Please Confirm the below details.",
      "wrap": true
    },
    {
      "type": "FactSet",
      "facts": [
        {
          "title": "First Name:",
          "value": "${dialog.CandidateFirstName}"
        },
        {
          "title": "Last Name:",
          "value": "${dialog.CandidateLastName}"
        },
        {
          "title": "Email:",
          "value": "${dialog.CandidateEmail}"
        },
        {
          "title": "Job Number(s):",
          "value": "${dialog.JobNumber}"
        }
      ]
    }
  ],
  "actions": [
    {
      "type": "Action.ShowCard",
      "title": "Update",
      "card": {
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "Input.Text",
            "id": "FirstName",
            "value": "${dialog.CandidateFirstName}"
          },
          {
            "type": "Input.Text",
            "id": "LastName",
            "value": "${dialog.CandidateLastName}"
          },
          {
            "type": "Input.Text",
            "id": "Email",
            "value": "${dialog.CandidateEmail}"
          },
          {
            "type": "Input.Text",
            "id": "JobNumber",
            "value": "${dialog.JobNumber}"
          }
        ],
        "actions": [
          {
            "type": "Action.Submit",
            "title": "OK",
            "associatedInputs": "auto",
            "style": "positive",
            "data": {
              "msteams": {
                "type": "update"
              }
            }
          },
          {
            "type": "Action.Submit",
            "title": "Cancel",
            "data": {
              "msteams": {
                "type": "cancelupdate"
              }
            },
            "associatedInputs": "none"
          }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
      }
    },
    {
      "type": "Action.Submit",
      "title": "Submit",
      "associatedInputs": "auto",
      "data": {
        "msteams": {
          "type": "submit"
        }
      }
    },
    {
      "type": "Action.Submit",
      "title": "Cancel",
      "associatedInputs": "none",
      "data": {
        "msteams": {
          "type": "cancel"
        }
      }
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.3"
}

dmvtech avatar Dec 29 '21 23:12 dmvtech

@dmvtech I tried the above adaptive card but the problem still exists...

shrutinehra avatar Dec 30 '21 09:12 shrutinehra

Hi @shrutinehra, are you able to share the repository of your bot to debug/reproduce this issue?

ram-xv avatar Jan 05 '22 17:01 ram-xv

Closing due to inactivity and inability to reproduce. If you can share with us a reproducible sample, please reopen or comment here and we can continue.

dmvtech avatar Jan 18 '22 18:01 dmvtech