Microsoft Teams approval

bun · 50 lines
1
import * as orvanta from "@orvanta/client"
2
 
3
// Orvanta 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 orvanta.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 orvanta.TeamsService.sendMessageToConversation({requestBody: { conversation_id, text: "A workflow has been suspended and is waiting for approval!", card_block }})
50
}
Orvanta Hub — community scripts, flows, apps & resource types.