I wrote a script in Google's Apps Script that sends data from Google Sheets as a message to Slack formatted in blocks.
Now I want the message to be of variable length depending on how many lines I have in my spreadsheet and I only want to send 1 message to prevent spamming channels with dozens of messages at the same time.
My first instinct was that this should be possible but simply combining 2 (or more) variables that look like they do below does not work. I have also tried splitting the message in even smaller parts to combine that later but that didn't work either.
var message = {
"blocks": [
{
"type": "section",
"text": {
"type": "plain_text",
"text": "This is a plain text section block.",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "plain_text",
"text": "This is a plain text section block.",
"emoji": true
}
}
]
}
Is there any way to combine multiple blocks into one message or maybe even a way to process the data before making the blocks so that it can be of a variable length?