MS Teams and adaptive Cards

Hello,

i just did try to send a simple adaptive card to MS Teams. I did try the following way:

  1. action Server

class Welcome(Action): def name(self) → Text: return “action_welcome”

async def run(
    self,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
) -> List[EventType]:

    message ={ "type": "AdaptiveCard",  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",  "version": "1.3", "body": [{  "type": "TextBlock", "text": "New TextBlock","wrap": True }]}

    dispatcher.utter_message(json_message = message)
    return []

which ends up with the error: 2021-07-13 17:04:33 INFO root - Rasa server is up and running. 2021-07-13 17:04:51 ERROR rasa.core.channels.botframework - Exception when trying to handle message.‘str’ object has no attribute ‘setdefault’

Is there any working example of MS Teams cards in action Server?

content of the message send to MS Teams: {‘type’: ‘AdaptiveCard’, ‘$schema’: ‘http://adaptivecards.io/schemas/adaptive-card.json’, ‘version’: ‘1.3’, ‘body’: [ {‘type’: ‘TextBlock’, ‘text’: ‘New TextBlock’, ‘wrap’: True}], ‘recipient’: {‘id’: ‘xxxg’}, ‘from’: {‘id’: ‘2xxx2’, ‘name’: ‘xxxTest’}, ‘channelData’: {‘notification’: {‘alert’: ‘true’}}, ‘text’: ‘’}

correct code:

class Welcome(Action): def name(self) → Text: return “action_welcome”

async def run(
    self,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
) -> List[EventType]:


    newmessage = {
      "attachments": [
        {
          "contentType": "application/vnd.microsoft.card.adaptive",
          "content": {
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [
              {
                "type": "TextBlock",
                "text": "Hello World!",
                "size": "large"
              },
              {
                "type": "TextBlock",
                "text": "*Sincerely yours,*"
              },
              {
                "type": "TextBlock",
                "text": "Adaptive Cards",
                "separation": "none"
              }
            ],
            "actions": [
              {
                "type": "Action.OpenUrl",
                "url": "http://adaptivecards.io",
                "title": "Learn More"
              }
            ]
          }
        }
      ]
    }
    dispatcher.utter_message(json_message = newmessage)


    return []