How to write the script of alarm notification to show in channel of microsoft teams?

I would like to use alarm notification. Could you share script for me,please?

I’m not sure you can send notifications to teams directly from the alarm/pipeline configuration…
But you can send a notification email or text message, and then I’m sure there are ways of forwarding those to a teams channel.

1 Like

team groups have an email address.
i blurred mine out but its where the arrow points too xd

2 Likes

Thank you very much.

I didnt completely test this out, but this should roughly get you on the right path.

EDIT: Replaced this with a version that I just tested and posted to a teams chat!

def msTeams(val):
    import system
   
    url = "https://outlook.office.com/webhook/" \
           "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx@xxxxxx-xxx-xxx-xxx-xxxxx/" \
           "IncomingWebhook/xxxxxxxxxxxxxxxx/" \
           "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx"
    contentType = "application/json"
   
    brutData = {
        "@type": "MessageCard",
        "@context": "http://schema.org/extensions",
        "themeColor": "0076D7",
        "summary": "Ignition Notification Message",
        "sections": [{
                    "activityTitle": "Ignition Notification Message",
                    "activitySubtitle": "Ignition Web Service",
                    "activityImage": "https://avatars0.githubusercontent.com/u/26392698?s=400&v=4",
                    "facts": [{
                        "name": "Message",
                        "value": val},
                        {"name": "Date",
                        "value": system.date.now()
                        },
                    ]
                }]
            }
   
    postData = system.util.jsonEncode(brutData)
    result = system.net.httpPost(url, contentType, postData)
    return result
3 Likes