Multi-column status report
Every language builds a complete message with the same fallback text and a two-column table: Service/Status, API/Healthy, Worker/Degraded. For formatted cells and column alignment, see Using Blocks. These examples print JSON without sending it.
Output
Local preview of the selected language’s tested example. Slack client appearance may differ; controls here do not send requests.
| Service | Status |
| API | Healthy |
| Worker | Degraded |
Serialized output
{
"channel": "C1",
"mrkdwn": true,
"blocks": [
{
"type": "table",
"block_id": "<generated-block-id>",
"rows": [
[
{
"type": "raw_text",
"text": "Service"
},
{
"type": "raw_text",
"text": "Status"
}
],
[
{
"type": "raw_text",
"text": "API"
},
{
"type": "raw_text",
"text": "Healthy"
}
],
[
{
"type": "raw_text",
"text": "Worker"
},
{
"type": "raw_text",
"text": "Degraded"
}
]
]
}
],
"text": "Service status"
}
Code
Shared example contract: The same service-status message in every language: Service/Status, API/Healthy and Worker/Degraded.
from slackblocks import Message, RawText, TableBlock
rows = [[RawText(text) for text in row] for row in [
["Service", "Status"], ["API", "Healthy"], ["Worker", "Degraded"],
]]
report = Message(channel="C1", text="Service status", blocks=[TableBlock(rows=rows)])
print(report.json())
import * as S from "@nicklambourne/slackblocks";
const table = S.TableBlock()
.rows([S.RawText().text("Service"), S.RawText().text("Status")])
.rows([S.RawText().text("API"), S.RawText().text("Healthy")])
.rows([S.RawText().text("Worker"), S.RawText().text("Degraded")]);
const message = S.Message().channel("C1").text("Service status").blocks(table).build();
console.log(JSON.stringify(message));
package main
import (
"encoding/json"
s "github.com/nicklambourne/slackblocks/go/v4"
"os"
)
func main() {
value, err := s.NewMessage().Channel("C1").Text("Service status").Blocks(s.NewTableBlock().Rows(
[]s.TableCell{s.NewRawText().Text("Service"), s.NewRawText().Text("Status")},
[]s.TableCell{s.NewRawText().Text("API"), s.NewRawText().Text("Healthy")},
[]s.TableCell{s.NewRawText().Text("Worker"), s.NewRawText().Text("Degraded")},
)).Build()
if err != nil {
panic(err)
}
if err := json.NewEncoder(os.Stdout).Encode(value); err != nil {
panic(err)
}
}
import io.github.nicklambourne.slackblocks.*;
import io.github.nicklambourne.slackblocks.block.*;
import io.github.nicklambourne.slackblocks.component.*;
import io.github.nicklambourne.slackblocks.element.*;
import io.github.nicklambourne.slackblocks.object.*;
import io.github.nicklambourne.slackblocks.payload.*;
import java.util.List;
import java.util.Map;
public final class Recipe {
public static void main(String[] args) throws Exception {
var table = TableBlock.builder().rows(
List.of(RawText.of("Service"), RawText.of("Status")),
List.of(RawText.of("API"), RawText.of("Healthy")),
List.of(RawText.of("Worker"), RawText.of("Degraded"))).build();
var value = MessagePayload.builder().channel("C1").text("Service status").blocks(table).build();
System.out.println(value.toJson());
}
}
using System;
using System.Collections.Generic;
using Slackblocks;
using Slackblocks.Blocks;
using Slackblocks.Components;
using Slackblocks.Elements;
using Slackblocks.Objects;
using Slackblocks.Payloads;
var table = new TableBlock(rows: [
[new RawText("Service"), new RawText("Status")],
[new RawText("API"), new RawText("Healthy")],
[new RawText("Worker"), new RawText("Degraded")],
]);
var message = new MessagePayload("C1", text: "Service status", blocks: [table]);
Console.WriteLine(message.ToJson());
require "slackblocks"
include Slackblocks
table = TableBlock.new(rows: [
[RawText.new(text: "Service"), RawText.new(text: "Status")],
[RawText.new(text: "API"), RawText.new(text: "Healthy")],
[RawText.new(text: "Worker"), RawText.new(text: "Degraded")]
])
message = MessagePayload.new(channel: "C1", text: "Service status", blocks: [table])
puts message.to_json
use slackblocks::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let table = TableBlock::builder()
.rows([
vec![RawText::new("Service")?, RawText::new("Status")?],
vec![RawText::new("API")?, RawText::new("Healthy")?],
vec![RawText::new("Worker")?, RawText::new("Degraded")?],
])
.build()?;
let message = MessagePayload::builder("C1").text("Service status").block(table).build()?;
println!("{}", serde_json::to_string(&message)?);
Ok(())
}
Plain tables permit ragged rows; data tables require rectangular rows and raw
header cells. DataTableBlock also checks its caption and text totals.
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Slackblocks as S;
$table = new S\TableBlock(rows: [
[new S\RawText('Service'), new S\RawText('Status')],
[new S\RawText('API'), new S\RawText('Healthy')],
[new S\RawText('Worker'), new S\RawText('Degraded')],
]);
$message = new S\MessagePayload(channel: 'C1', text: 'Service status', blocks: [$table]);
echo $message->toJson();
alias Slackblocks.{Message, Blocks.Table, Objects.RawText}
rows = for row <- [["Service", "Status"], ["API", "Healthy"], ["Worker", "Degraded"]] do
for text <- row, do: RawText.new!(text: text)
end
Message.new!(channel: "C1", text: "Service status", blocks: [Table.new!(rows: rows)])
|> Slackblocks.to_map!()
{-# LANGUAGE OverloadedStrings #-}
import Data.Aeson (encode)
import qualified Data.Map.Strict as Map
import Slackblocks
example = do
rows <-
traverse
(traverse (fmap rawTextAsTableCell . buildRawText . rawText))
[["Service", "Status"], ["API", "Healthy"], ["Worker", "Degraded"]]
table <- buildTableBlock (tableBlock rows)
buildMessagePayload ((messagePayload "C1") {messagePayloadText = Just "Service status", messagePayloadBlocks = Just [tableBlockAsBlock table]})