This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildReport() { | |
const ss = SpreadsheetApp.getActive(); | |
const data = ss.getSheetByName('SUMMARY').getRange("A1").getValues(); | |
const payload = buildAlert(data); | |
Logger.log(data); | |
sendAlert(payload); | |
} | |
function buildAlert(data) { | |
const mrr = data[0][0]; | |
const payload = { | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": ":bell: *Daily MRR Report* :bell:" | |
} | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "Our NET MRR for this month is " + mrr | |
} | |
} | |
] | |
}; | |
return payload; | |
} | |
function sendAlert(payload) { | |
const webhook = "https://hooks.slack.com/services/<your-webhook-goes-here>"; | |
const options = { | |
"method": "post", | |
"contentType": "application/json", | |
"muteHttpExceptions": true, | |
"payload": JSON.stringify(payload) | |
}; | |
try { | |
UrlFetchApp.fetch(webhook, options); | |
} catch(e) { | |
Logger.log(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment