Skip to main content

Metadata and safe edits

Keep application metadata attached while constructing an updated message. Follow each language’s ownership rules; metadata is not visible message content.

Output

Local preview of the selected language’s tested example. Slack client appearance may differ; controls here do not send requests.

Updated
Metadata accompanies the message and is not shown in Slack.
{
"event_type": "build",
"event_payload": {
"count": 0,
"enabled": false,
"missing": null
}
}
Serialized output
{
"channel": "C1",
"mrkdwn": true,
"text": "Updated",
"metadata": {
"event_type": "build",
"event_payload": {
"count": 0,
"enabled": false,
"missing": null
}
}
}

Code​

Metadata is application data, not visible Slack message content. Copy Python models before changing a shared template.

from copy import deepcopy
from slackblocks import Message

original = Message(channel="C1", text="Ready", metadata={
"event_type": "build", "event_payload": {"count": 0, "enabled": False, "missing": None},
})
updated = deepcopy(original) # Python models are mutable.
updated.text = "Updated"
assert original.text == "Ready"
print(updated.json())