0

Send a message to MS Teams channel via webhook

by
Published May 26, 2023

Send a message to a MS Teams channel via webhook. Requires a MS Teams Resource and a MS Teams format Message Card. Example Message Card: { "@type": "MessageCard", "@context": "https://schema.org/extensions", "summary": "This is a test summary", "themeColor": "0078D7", "title": "This is a test title", "sections": [ { "activityTitle": "Windmill Webhook", "activitySubtitle": "2023-05-25 17:57:55", "activityImage": "https://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg", "text": "This is a test text" } ] }

Script msteams Verified

The script

Submitted by hugo989 Bun
Verified 14 days ago
1
import { IncomingWebhook } from "[email protected]";
2

3
// See below for an example card you can pass in
4

5
type MsTeamsWebhook = {
6
  webhook_url: string;
7
};
8
export async function main(
9
  ms_teams_webhook: MsTeamsWebhook,
10
  messageCard: object,
11
) {
12
  const webhook = new IncomingWebhook(ms_teams_webhook.webhook_url);
13
  const ret = await webhook.send(messageCard);
14
  return ret;
15
}
16

17
const example_card = {
18
  "@type": "MessageCard",
19
  "@context": "https://schema.org/extensions",
20
  summary: "This is a test summary",
21
  themeColor: "0078D7",
22
  title: "This is a test title",
23
  sections: [
24
    {
25
      activityTitle: "Windmill Webhook",
26
      activitySubtitle: "2023-05-25 17:57:55",
27
      activityImage:
28
        "https://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg",
29
      text: "This is a test text",
30
    },
31
  ],
32
};
33

Other submissions
  • Submitted by marco lussetti774 Deno
    Created 406 days ago
    1
    import { IncomingWebhook } from "npm:[email protected]";
    2
    
    
    3
    // See below for an example card you can pass in
    4
    
    
    5
    type MsTeamsWebhook = {
    6
      webhook_url: string;
    7
    };
    8
    export async function main(
    9
      ms_teams_webhook: MsTeamsWebhook,
    10
      messageCard: object,
    11
    ) {
    12
      const webhook = new IncomingWebhook(ms_teams_webhook.webhook_url);
    13
      const ret = await webhook.send(messageCard);
    14
      return ret;
    15
    }
    16
    
    
    17
    const example_card = {
    18
      "@type": "MessageCard",
    19
      "@context": "https://schema.org/extensions",
    20
      summary: "This is a test summary",
    21
      themeColor: "0078D7",
    22
      title: "This is a test title",
    23
      sections: [
    24
        {
    25
          activityTitle: "Windmill Webhook",
    26
          activitySubtitle: "2023-05-25 17:57:55",
    27
          activityImage:
    28
            "https://connectorsdemo.azurewebsites.net/images/MSC12_Oscar_002.jpg",
    29
          text: "This is a test text",
    30
        },
    31
      ],
    32
    };
    33