Search code examples
botframeworkwebhooksmicrosoft-teams

Adaptive Card's messageBack action for msteams provided by outgoing webhook fails with "The resource URL is misformatted."


I have followed Extend Microsoft Teams Exercise - Create outgoing webhooks 3-exercise-outgoing-webhooks to build a MS Teams Outgoing webhook, and successfully it returns planet themed Adaptive Cards.

However, when I add a new messageBack action, following guidance on special Adaptive Card functionality that is specific to the Microsoft Teams channel, it fails in its reply to the webhook.

The added action I have used is copied verbatim and added to the actions list for planetDisplayCard.json:

  "actions": [
    {
      "type": "Action.OpenUrl",
      "title": "Learn more on Wikipedia"
    },
    {
      "type": "Action.Submit",
      "title": "Click me for messageBack",
      "data": {
        "msteams": {
            "type": "messageBack",
            "displayText": "I clicked this button",
            "text": "text to bots",
            "value": "{\"bfKey\": \"bfVal\", \"conflictKey\": \"from value\"}"
        }
      }
    }

The card renders in Teams, but when the button is clicked the following happen:

  • Unexpected: We see Something went wrong. Please try again.
  • Expected: The chat includes the displayText "I clicked this button"
  • Unexpected: the dev tools report a 400 code return from the POST to https://emea.ng.msg.teams.microsoft.com/v1/agents/xxxxxx-xxxx-xxxx-xxxx-redacted/invokewith the body {"errorCode":201,"message":"The resource URL is misformatted."}
    • the tools show the request body {clientMessageId: "11862533962269802517" conversation: {id: "19:xxxxxxxxxxxxxxxxxxxredacted@thread.skype;messageid=1603494001316"} imdisplayname: "My Name" messageType: "RichText/Media_Card" name: "messageback" serverMessageId: "1603539459992" text: "text to bots" value: {bfKey: "bfVal", conflictKey: "from value"} bfKey: "bfVal" conflictKey: "from value"}

I have also seen this same problem with a HeroCard messageBack CardAction for my own hosted webhook service; but in trying to diagnose the problem I have reproduced with same fail with the Yeoman Generator for Microsoft Teams on my local dev environment.

A picture to illustrate my dev environment where it is all going wrong

Do messageBack Actions work with Outgoing Webhooks in MS Teams ?


Solution

  • I've not tested this exact scenario, but an outgoing webhook is -similar- in some ways to a bot, but not as fully featured, and can't handle multiple steps in an action like this, to my knowledge. The "Card Actions" article you've linked to basically says as much in the intro paragraph:

    Cards used by bots and messaging extensions...

    As a result, I'd suggest rather building a full-blown Teams bot for this scenario. You can have a look here to get started on that, and of course ask any questions here on S.overflow if you're stuck.