1

I've created a bot using Microsoft Bot Framework Composer and displaying the following Adaptive Card. How can I determine what button is pressed when the message is submitted using Action.Submit and Task/Fetch?

{
  "type": "AdaptiveCard",
  "body": [
    {
      "type": "TextBlock",
      "size": "Medium",
      "weight": "Bolder",
      "text": "Publish Adaptive Card Schema"
    }
  ],
  "actions": [
    {
      "type": "Action.ShowCard",
      "title": "Set due date",
      "card": {
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "Input.Date",
            "id": "dueDate"
          },
          {
            "type": "Input.Text",
            "id": "comment",
            "placeholder": "Add a comment",
            "isMultiline": true
          }
        ],
        "actions": [
          {
            "type": "Action.Submit",
            "title": "OK",
            "data": {
              "msteams": {
                "type": "task/fetch",
                "value": {
                  "option": "opt1"
                }
              }
            }
          }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
      }
    },
    {
      "type": "Action.OpenUrl",
      "title": "View",
      "url": "https://adaptivecards.io"
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.3"
}

My bot correctly receives the submitted message, but I cannot tell which button is pressed. The following is an example of this.activity sent. I can see the msteams type is set to task/fetch, but cannot tell what button was pressed in the above card.

{
  "type": "invoke",
  "id": "",
  "timestamp": "2021-06-29T16:57:27.551-05:00",
  "localTimestamp": "2021-06-29T16:57:27.551-05:00",
  "localTimezone": "America/Chicago",
  "serviceUrl": "https://smba.trafficmanager.net/amer/",
  "channelId": "msteams",
  "from": {
    "id": "",
    "name": "Mike",
    "aadObjectId": ""
  },
  "conversation": {
    "conversationType": "personal",
    "id": "",
    "tenantId": ""
  },
  "recipient": {
    "id": "",
    "name": "csharpdemo"
  },
  "locale": "en-US",
  "entities": [
    {
      "type": "clientInfo",
      "locale": "en-US",
      "country": "US",
      "platform": "Windows",
      "timezone": "America/Chicago"
    }
  ],
  "channelData": {
    "tenant": {
      "id": ""
    },
    "source": {
      "name": "compose"
    },
    "legacy": {
      "replyToId": ""
    }
  },
  "replyToId": "",
  "value": {
    "data": {
      "type": "task/fetch"
    },
    "context": {
      "theme": "default"
    }
  },
  "name": "task/fetch",
  "callerId": "urn:botframework:azure"
}

It looks like I need to pass a value or data field in the msteams node but not sure how.

enter image description here

https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-actions?tabs=json#adaptive-cards-actions

https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/

Teams Bot Adaptive Card action.Submit returns undefined but works in Bot Emulator

mercer
  • 321
  • 1
  • 3
  • 12
  • I am not familiar with bot composer but I have one clarification, Is there any possible way to add custom information inside " "data": {"msteams": {"}}} in bot composer. Then we can identify which button clicked inside ms team chatbot. Because normal chatbot other than bot composer we have used this kind of requirements and we have achieved this scenario. let me know if customization is possible then i will update you the answer. – Rajeesh Menoth Jun 30 '21 at 09:08

1 Answers1

0

You can include additional hidden properties in the data object, if required.

{
  "type": "Action.Submit",
  "title": "submit",
  "data": {
    "msteams": {
        "type": "task/fetch"
    },
    "Value1": "some value"
  }
}

https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-actions?tabs=json#adaptive-cards-actions

mercer
  • 321
  • 1
  • 3
  • 12