SOLVED
Home

Send adaptive card via Powershell to a Teams Channel

%3CLINGO-SUB%20id%3D%22lingo-sub-1155523%22%20slang%3D%22en-US%22%3ESend%20adaptive%20card%20via%20Powershell%20to%20a%20Teams%20Channel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1155523%22%20slang%3D%22en-US%22%3E%3CP%3EI%20created%20an%20adaptive%20card%20and%20want%20to%20send%20it%20via%20PowerShell%20to%20a%20Teams%20Channel%20via%20a%20webhook.%20Everything%20works%20so%20far%2C%20but%20the%20card%20is%20shown%20as%20a%20blank%20line%3F!%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fsad_40x40_1.gif%22%20alt%3D%22%3Asad%3A%22%20title%3D%22%3Asad%3A%22%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Annotation.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F169395i36A70B6842B1A9D0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Annotation.png%22%20alt%3D%22Annotation.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1155523%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdaptive%20card%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ewebhook%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1159799%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20adaptive%20card%20via%20Powershell%20to%20a%20Teams%20Channel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1159799%22%20slang%3D%22en-US%22%3EAnyone%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1162648%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20adaptive%20card%20via%20Powershell%20to%20a%20Teams%20Channel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1162648%22%20slang%3D%22en-US%22%3ECan%20you%20paste%20the%20card%20you%E2%80%99re%20sending%3F%3CBR%20%2F%3E%3CBR%20%2F%3EIt%20should%20work%3B%20but%20Teams%20doesn%E2%80%99t%20fully%20support%20all%20of%20the%20latest%20Adaptive%20Card%20stuff%2C%20so%20it%20might%20be%20that.%20Sometimes%20it%E2%80%99s%20a%20case%20of%20starting%20small%20and%20then%20building%20it%20back%20up%20to%20see%20where%20it%20breaks.%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1163576%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20adaptive%20card%20via%20Powershell%20to%20a%20Teams%20Channel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1163576%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7960%22%20target%3D%22_blank%22%3E%40Tom%20Morgan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%24body%20%3D%20%40%22%0A%7B%0A%20%20%20%20%22%24schema%22%3A%20%22http%3A%2F%2Fadaptivecards.io%2Fschemas%2Fadaptive-card.json%22%2C%0A%20%20%20%20%22type%22%3A%20%22AdaptiveCard%22%2C%0A%20%20%20%20%22version%22%3A%20%221.0%22%2C%0A%20%20%20%20%22summary%22%3A%20%22Adaptive%20Card%20Test%22%2C%0A%20%20%20%20%22body%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22TextBlock%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22text%22%3A%20%22Using%20Microsoft%20Teams%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22size%22%3A%20%22Large%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22weight%22%3A%20%22Bolder%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22Image%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22altText%22%3A%20%22%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22url%22%3A%20%22https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FWOIGpnJ3ye445BUQl4%2Fgiphy.gif%22%0A%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22TextBlock%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22text%22%3A%20%22Please%20make%20sure%20to%20read%20the%20User%20Guide%20first.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22horizontalAlignment%22%3A%20%22Left%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22height%22%3A%20%22stretch%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22wrap%22%3A%20true%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%5D%2C%0A%20%20%20%20%22selectAction%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22type%22%3A%20%22Action.OpenUrl%22%2C%0A%20%20%20%20%20%20%20%20%22title%22%3A%20%22Request%20Office%20365%20Group%22%2C%0A%20%20%20%20%20%20%20%20%22url%22%3A%20%22https%3A%2F%2Fteams.microsoft.com%2Fxyz%22%0A%20%20%20%20%7D%2C%0A%20%20%20%20%22actions%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22type%22%3A%20%22Action.OpenUrl%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22title%22%3A%20%22Request%20Office%20365%20Group%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22url%22%3A%20%22https%3A%2F%2Fteams.microsoft.com%2Fxyz%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%5D%0A%7D%0A%22%40%0A%0A%24uri%20%3D%20'https%3A%2F%2Foutlook.office.com%2Fwebhook%2Fxyz'%0A%0AInvoke-RestMethod%20-uri%20%24uri%20-Method%20Post%20-body%20%24body%20-ContentType%20'application%2Fjson'%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1163663%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20adaptive%20card%20via%20Powershell%20to%20a%20Teams%20Channel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1163663%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F517500%22%20target%3D%22_blank%22%3E%40Thomas_Steibl%3C%2FA%3E%26nbsp%3B%20Ah%2C%20ok%2C%20so%20I%20forgot%20something%20really%20important!%26nbsp%3B%20You%20can't%20use%20Adaptive%20Cards%2C%20you%20have%20to%20use%20the%20older%20MessageCard%20format.%20See%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foutlook%2Factionable-messages%2Fsend-via-connectors%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foutlook%2Factionable-messages%2Fsend-via-connectors%3C%2FA%3E%26nbsp%3Bfor%20the%20detail%2C%20but%20this%20should%20work%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CPRE%3E%24body%20%3D%20'%20%7B%0A%20%20%22%40context%22%3A%20%22https%3A%2F%2Fschema.org%2Fextensions%22%2C%0A%20%20%22%40type%22%3A%20%22MessageCard%22%2C%0A%20%20%22themeColor%22%3A%20%220072C6%22%2C%0A%20%20%22title%22%3A%20%22Using%20Microsoft%20Teams%22%2C%0A%20%20%22text%22%3A%20%22Please%20make%20sure%20to%20read%20the%20User%20Guide%20first.%22%2C%0A%20%20%22potentialAction%22%3A%20%5B%0A%20%20%20%20%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22%40type%22%3A%20%22OpenUri%22%2C%0A%20%20%20%20%20%20%22name%22%3A%20%22Request%20Office%20365%20Group%22%2C%0A%20%20%20%20%20%20%22targets%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%7B%20%22os%22%3A%20%22default%22%2C%20%22uri%22%3A%20%22https%3A%2F%2Fteams.microsoft.com%2Fl%2Fentity%2F81fef3a6-72aa-4648-a763-de824aeafb7d%2F_djb2_msteams_prefix_316372079%3Fcontext%3D%257B%2522subEntityId%2522%253Anull%252C%2522channelId%2522%253A%252219%253A96f7bce5c6e2472a8f6e896ef0e4f875%2540thread.skype%2522%257D%26amp%3BgroupId%3Dd622b046-74e2-46a4-a1c6-63411f915464%26amp%3BtenantId%3D5176709f-3f1f-4e44-a034-277655f7629c%22%20%7D%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%0A%20%20%5D%0A%7D'%0A%3C%2FPRE%3E%0A%3CP%3EShould%20give%20you%3A%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorTom%20Morgan_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222020-02-10%2008_58_13-POC%20Channel%20(Development)%20_%20Microsoft%20Teams.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F170026i1838165057FF6FD0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%222020-02-10%2008_58_13-POC%20Channel%20(Development)%20_%20Microsoft%20Teams.png%22%20alt%3D%222020-02-10%2008_58_13-POC%20Channel%20(Development)%20_%20Microsoft%20Teams.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1163693%22%20slang%3D%22en-US%22%3ERe%3A%20Send%20adaptive%20card%20via%20Powershell%20to%20a%20Teams%20Channel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1163693%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7960%22%20target%3D%22_blank%22%3E%40Tom%20Morgan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eoh%20wow%20okay.%20Thanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%20if%20adaptive%20cards%20are%20coming%20to%20Teams%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

I created an adaptive card and want to send it via PowerShell to a Teams Channel via a webhook. Everything works so far, but the card is shown as a blank line?! :sad:

 

Annotation.png

5 Replies
Highlighted
Highlighted
Can you paste the card you’re sending?

It should work; but Teams doesn’t fully support all of the latest Adaptive Card stuff, so it might be that. Sometimes it’s a case of starting small and then building it back up to see where it breaks.
Highlighted

@Tom Morgan 

 

$body = @"
{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.0",
    "summary": "Adaptive Card Test",
    "body": [
        {
            "type": "TextBlock",
            "text": "Using Microsoft Teams",
            "size": "Large",
            "weight": "Bolder"
        },
        {
            "type": "Image",
            "altText": "",
            "url": "https://media.giphy.com/media/WOIGpnJ3ye445BUQl4/giphy.gif"
        },
        {
            "type": "TextBlock",
            "text": "Please make sure to read the User Guide first.",
            "horizontalAlignment": "Left",
            "height": "stretch",
            "wrap": true
        }
    ],
    "selectAction": {
        "type": "Action.OpenUrl",
        "title": "Request Office 365 Group",
        "url": "https://teams.microsoft.com/xyz"
    },
    "actions": [
        {
            "type": "Action.OpenUrl",
            "title": "Request Office 365 Group",
            "url": "https://teams.microsoft.com/xyz"
        }
    ]
}
"@

$uri = 'https://outlook.office.com/webhook/xyz'

Invoke-RestMethod -uri $uri -Method Post -body $body -ContentType 'application/json'

 

Highlighted
Solution

@Thomas_Steibl  Ah, ok, so I forgot something really important!  You can't use Adaptive Cards, you have to use the older MessageCard format. See https://docs.microsoft.com/en-us/outlook/actionable-messages/send-via-connectors for the detail, but this should work:


$body = ' {
  "@context": "https://schema.org/extensions",
  "@type": "MessageCard",
  "themeColor": "0072C6",
  "title": "Using Microsoft Teams",
  "text": "Please make sure to read the User Guide first.",
  "potentialAction": [
    
    {
      "@type": "OpenUri",
      "name": "Request Office 365 Group",
      "targets": [
        { "os": "default", "uri": "https://teams.microsoft.com/l/entity/81fef3a6-72aa-4648-a763-de824aeafb7d/_djb2_msteams_prefix_316372079?context=%7B%22subEntityId%22%3Anull%2C%22channelId%22%3A%2219%3A96f7bce5c6e2472a8f6e896ef0e4f875%40thread.skype%22%7D&groupId=d622b046-74e2-46a4-a1c6-63411f915464&tenantId=5176709f-3f1f-4e44-a034-277655f7629c" }
      ]
    }
  ]
}'

Should give you:

 

2020-02-10 08_58_13-POC Channel (Development) _ Microsoft Teams.png

Highlighted

@Tom Morgan 

oh wow okay. Thanks!

 

Any ideas if adaptive cards are coming to Teams?

Related Conversations