cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 9

Microsoft Teams ActiveCard Webhook - using a variable in the URL: field

I have MS Teams working with ActiveCard 1.2 format and webhooks.  I'm happy with the format.  My issue is that MS Teams channels via webhook don't yet support @mentions, so the only way to really filter is to have different alerts go to different channels for the various teams.  I'd really like to do this with 1 alert - the problem is I need a variable working in the URL box.  Right now, variables are rejected for some reason.  Is there a way to get this box to accept a variable so I don't have to make 15 duplicate copies of the same alert with a different URL in each one?  It's just frustrating when you run into little quirks like this.

See sample image - the red highlight is not accepted unless I put a raw URL in there.

URL not accepted.png

 

Also for reference, here is my ActiveCard I'm using.  The card has several action buttons and an expanding info window that gives out some of our custom fields.  Here is the compact card:

down alert.png

 Here is the same card expanded with more information about the system:

Down Expanded.png

Here is the body of the Post for a Down alert.  I do pull in a lot of custom fields so if you want to use this format you might need to remove them.

 

{
    "type": "message",
    "attachments": [
        {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "contentUrl": null,
            "content": {
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                "type": "AdaptiveCard",
                "version": "1.2",
                "body": [


                    {
                        "type":"ColumnSet",
                        "columns":[
                            {
                              "type":"Column",
                              "padding":"None",
                              "width":"auto",
                              "items":[
                                 {
                                    "type":"Image",
                                    "url":"https://www.iconsdb.com/icons/preview/red/down-xxl.png",
                                    "size":"Small"
                                 }
                              ],
                              "horizontalAlignment":"Left"
                           },
                           {
                              "type":"Column",
                              "padding":"None",
                              "width":"stretch",
                              "items":[
                                 {
                                    "type":"TextBlock",
                                    "text":"${N=SwisEntity;M=CustomProperties.Monitoring}: ${N=SwisEntity;M=Caption} at ${IP_Address} is ${N=SwisEntity;M=Status}",
                                    "wrap":true
                                 }
                              ],
                              "verticalContentAlignment":"Center"
                           }

      
                        ] 
                    }


                ],
                    "actions": [
                    {
                        "type": "Action.ShowCard",
                        "title": "More Info",
                        "card": {
                            "type": "AdaptiveCard",
                            "body": [
                                {
                                    "type": "TextBlock",
                                    "text": "Node Name: ${NodeName}",
                                    "size": "Medium",
                                    "wrap": true
                                },                                
                                {
                                    "type": "TextBlock",
                                    "text": "System Name: ${DNS}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "IP Address: ${IP_Address}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "Time of Alert: ${Date} ${Time}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "Monitoring: ${N=SwisEntity;M=CustomProperties.Monitoring}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "Device Type: ${N=SwisEntity;M=CustomProperties.DeviceType}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "Site: ${N=SwisEntity;M=CustomProperties.Site}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "Location: ${location}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "Contact: ${N=SwisEntity;M=Contact}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "Comment: ${N=SwisEntity;M=CustomProperties.Comments}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "EmailPrimary: ${N=SwisEntity;M=CustomProperties.EmailPrimary}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "EmailSecondary: ${N=SwisEntity;M=CustomProperties.EmailSecondary}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "ON Call Text: ${N=SwisEntity;M=CustomProperties.EmailOnCall}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "On Call Escalation: ${N=SwisEntity;M=CustomProperties.EmailEscalation}",
                                    "size": "Medium",
                                    "wrap": true
                                },
                                {
                                    "type": "TextBlock",
                                    "text": "Open Alert: [${N=Alerting;M=AlertDetailsUrl}](${N=Alerting;M=AlertDetailsUrl})",
                                    "size": "Medium",
                                    "wrap": true
                                },          
                            ],
                            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
                        }
                    },     
                    {
                        "type": "Action.OpenUrl",
                        "title": "Open Node",
                        "url": "${N=SwisEntity;M=DetailsUrl}"
                    },
                    {
                        "type": "Action.OpenUrl",
                        "title": "Acknowledge ",
                        "url": "${N=Alerting;M=AcknowledgeLink}"
                    }
                ]
            }
        }
    ]
}

 

 

3 Replies
Level 11

BUMP, DITTO, Please save us Obi wan developers.... 

Love the use of Custom Properties, and completely agree with how you are trying to use them. I am surprised that this cannot be done as you posted. I might be copying what you did, just swapping out the custom properties.😁 I like it as webhooks are starting to get a following around me. 

Thanks for sharing

Marc

Level 9

I brought this to their attention 3 months ago as well. This needs to be a thing! Setting the alert to call out the user or group responsible for the alert is the ONLY way to make teams alerts useful. Otherwise,everyone is seeing everything and it just becomes background noise and ignored eventually. This is critical to making the teams alerts an actually useful thing. 

Product Manager
Product Manager

Unfortunately, variables for the URL are not supported. I have created an internal Feature Request CUST-69408 to track this, as the only option available  to simplify this process for you would be to use a PowerShell script to do the POST in a similar way to what is described here

https://thwack.solarwinds.com/t5/NPM-Discussions/HTTP-Headers-in-Alert-Actions-POST-Get-URL/m-p/1818...