-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessagesender.js
51 lines (46 loc) · 1.74 KB
/
messagesender.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Sends messages to teams channel via webhook ("incoming webhook")
// https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook#create-an-incoming-webhook-1
const fetch = require('node-fetch')
const config = require('./config/config.json')
async function post_to_teams_channel(msg){
var teams_wh = config.teams_webhook
const body = {
"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": "TextBlock",
//"text": "For Samples and Templates, see [https://adaptivecards.io/samples](https://adaptivecards.io/samples)"
"text" : `${msg}`
}
]
}
}
]
}
//const response = await fetch("https://artsdatabankenno.webhook.office.com/webhookb2/99e9cecd-2822-4e2f-8bea-652d6cbeb92d@97c30119-98d7-4b74-8ad7-0ba9a09a94c1/IncomingWebhook/f219f9815ad14add8268f26583eb5be1/dfdee89f-d8d2-4d8a-a7bb-6d05162c0dfe", {
const response = await fetch(teams_wh, {
method: 'post',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json'}
});
const data = await response.text();
//console.log(data);
return data;
}
function say_hepp(){
console.log("hepp")
}
/*function test_conf_props(){
import info
}
*/
exports.say_hepp = say_hepp;
exports.post_to_teams_channel = post_to_teams_channel;