0
Microsoft Teams approval Approval
One script reply has been approved by the moderators Verified

Request approval from Microsoft Teams

Created by hugo697 19 days ago Viewed 399 times
0
Submitted by hugo697 Bun
Verified 19 days ago
1
import * as wmill from "windmill-client"
2

3
// Windmill Teams Bot required in OAuth Instance Settings
4
// conversation_id: e.g "19:49d9a024000e42f0877c599e84e49458@thread.tacv2"
5
export async function main(conversation_id: string, approver?: string) {
6
  const endpoints = await wmill.getResumeUrls(approver);
7

8
  // Modify as required:
9
  // https://adaptivecards.microsoft.com/designer
10
  const card_block = {
11
        "type": "message",
12
        "attachments": [
13
            {
14
                "contentType": "application/vnd.microsoft.card.adaptive",
15
                "content": {
16
                    "type": "AdaptiveCard",
17
                    "$schema": "https://adaptivecards.io/schemas/adaptive-card.json",
18
                    "version": "1.6",
19
                    "body": [
20
                        {
21
                            "type": "TextBlock",
22
                            "text": "Workflow Suspended",
23
                            "size": "Large",
24
                            "weight": "Bolder",
25
                            "wrap": true
26
                        },
27
                        {
28
                            "type": "TextBlock",
29
                            "text": "A workflow has been suspended and is waiting for approval!",
30
                            "wrap": true,
31
                        },
32
                        {
33
                          "type": "ActionSet",
34
                          "actions": [
35
                              {
36
                                  "type": "Action.OpenUrl",
37
                                  "title": "Resume or Cancel",
38
                                  "url": `${endpoints.approvalPage}`
39
                              }
40
                          ]
41
                        }
42
                    ],
43
                },
44
            }
45
        ],
46
        "conversation": {"id": `${conversation_id}`},
47
    }
48

49
  await wmill.TeamsService.sendMessageToConversation({requestBody: { conversation_id, text: "A workflow has been suspended and is waiting for approval!", card_block }})
50
}