MicrosoftDocs / msteams-docs

Source for the Microsoft Teams developer platform documentation.
https://aka.ms/teamsdev
Creative Commons Attribution 4.0 International
284 stars 506 forks source link

Adaptive Card sent via Bot with Action.Submit, msteams property and invoke - prompting to add app and empty popup? #6529

Open robinmalik opened 2 years ago

robinmalik commented 2 years ago

Hi,

I'm trying to pass data from an Adaptive Card within Microsoft Teams via Action.Submit, using the msteams property and the syntax required for an invoke action, and am getting odd behaviour in the Teams client.

I'm using the following documentation: https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-actions?tabs=json#adaptive-cards-actions where it says:

You can also modify the Adaptive Card Action.Submit payload to support existing Bot Framework actions using an msteams property in the data object of Action.Submit.

Payload sent to Teams by the bot:

{
  "type": "message",
  "summary": ": ",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "content": {
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "TextBlock",
            "size": "Large",
            "weight": "Bolder",
            "text": "Some Text",
            "color": "Default"
          }
        ],
        "separator": true,
        "actions": [
          {
            "type": "Action.Submit",
            "title": "Submit",
            "data": {
              "msteams": {
                "type": "task/fetch"
              },
              "Value1": "some value"
            }
          }
        ],
        "msteams": {
          "width": "Full"
        },
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.4"
      }
    }
  ]
}

When clicking the button for the first time it generates the following popup asking me to add the app (even though the app has been added):

image

After adding the app, clicking the submit button I can see that the bot receives the invoke payload but the desktop client generates this empty window which does nothing:

image

Additionally if I open up the Teams web client and try this, I also get the 'Add app' prompt but submit does nothing at all. The bot doesn't receive any payload.

For completeness, this is a bot registered via https://dev.botframework.com/bots functioning using an app registration, and this is being tested as a 'personal' app (so chatting directly with it).

ghost commented 2 years ago

Hi robinmalik! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

robinmalik commented 2 years ago

If I modify the JSON to use the messageBack action and send this into Teams, clicking the submit button results in the messageBack reply displaying in the teams client ("I clicked this button") and the payload being received by the bot again, but this time the frontend client issue reports "unable to reach app" very quickly. The bot isn't performing a long running operation.

image

This messageBack issue looks like the same issue as #6461 but the invoke issue is also a problem.

I'm running Teams 1.5.00.19563 (64-bit).

robinmalik commented 2 years ago

Going back to the invoke action. I found some documentation (https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/universal-action-model) detailing what I thought could be the issue but isn't mentioned in the first set of docs I saw.

I've now configured it so that the bot is responding with:

{"statusCode": 200, "type": "application/vnd.microsoft.activity.message", "value": "huh"}

Within a second or two of clicking the submit button:

image

Maybe this isn't the issue though. I'm clutching at straws.

robinmalik commented 2 years ago

Switching to Action.Execute and using a response of {"statusCode": 200, "type": "application/vnd.microsoft.activity.message", "value": "something you want the user to see in a grey bar under your adaptive card here"} solved this problem.

It seems like Action.Submit is the old method, based on: https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/universal-action-model

ghost commented 2 years ago

Tell us about your experience!

Hi robinmalik! This issue is closed in our system. We would like your feedback on your experience with our support team and Platform.

Best regards, Teams Platform

ghost commented 2 years ago

Hi robinmalik! Thank you for bringing this issue to our attention. We will investigate and if we require further information we will reach out in one business day. Please use this link to escalate if you don't get replies.

Best regards, Teams Platform

robinmalik commented 2 years ago

This is still a problem, even with Action.Execute and bot responses within a few seconds.

ChetanSharma-msft commented 2 years ago

@robinmalik - We will further investigate this issue and get back to you.

robinmalik commented 2 years ago

I may have managed to track down the issue; an internal call to Get-MGUser that wasn't triggering an exception, and thus no response was being sent in reply to the button press.

In the instance whereby internal logic fails to get/set data as intended by Action.Execute, we're supposed to return a non-200 status code as per: https://docs.microsoft.com/en-us/adaptive-cards/authoring-cards/universal-action-model#response-format - I'd like to return an error 500 so that I can return an error and hopefully rather than "unable to reach app" it displays the text sent, but the table here appears incomplete.

Can you please provide the schema / update the docs?

ChetanSharma-msft commented 2 years ago

Hello @robinmalik - Thanks for sharing your feedback. We will look into it and get back to you.

Meghana-MSFT commented 1 year ago

Apologies for the delay in response. It is not possible to send custom message instead of "unable to reach app". As a workaround you can update your adaptive card to display the error message that you want to show.

We have also raised a doc bug to update the active TODO links in the Supported status codes table.