Slack API attachments cheat sheet

What are attachments

A decoration for Slack messages. It is effective for enriching the messages posted by notification bots. The following image is a comparison between without attachment and with attachment.

No attachment

なし.png

with attachment

あり.png

Parameters

fallback

Commentary

A plain text summary for the attachment. According to the documentation, it appears on clients that don't display formatted text, but I haven't come across any clients or scenes that do yet. As the name "fallback" suggests, it's a good idea to specify a summary text of attachments just in case.

Specification example

"fallback": "This is test attachment",

color

Commentary

Specify the color of attachments. There are 3 types of presets, and it is also possible to specify by color code.

preset

The colors of the signal, such as blue, yellow, and red, respectively.

Designation by color code

It is also possible to specify any color with the color code. スクリーンショット 2017-07-01 14.24.48.png

Default

Attachments with no color specified are displayed as follows. スクリーンショット 2017-07-01 14.27.10.png

Specification example

preset


"color": "good",

Color code


"color": "#FFC0CB",

pretext

Commentary

Specifies the text to appear above the attachments block (the area that appears next to the ↑ color). If you have text in the message body as shown in the capture below, it will be indistinguishable.

pretext.png

It is effective when adding multiple attachments.

スクリーンショット 2017-07-01 14.39.05.png

Specification example

"pretext": "This is pretext",

author parameters

Commentary

A set of parameters that specify Author information (starting with ʻauthor_`).

author.png

Specification example

"author_name": "daikiojm",
"author_link": "http://qiita.com/daikiojm",
"author_icon": "https://avatars1.githubusercontent.com/u/10055293?v=3&u=1d1491fc3c27e10e93cc364ee0556a3b768c29b2&s=100"

title

Commentary

The title of attachment.

title.png

Specification example

"title": "TEST",

title_link

Commentary

The title link.

Specification example

"title_link": "http://qiita.com/daikiojm",

text

Commentary

The body of the attachment.

Specification example

"text": "test:goode",

Line breaks\at n


"text": "test:goode\ntest2",

fields

Commentary

It is used when you want to display multiple groups in one attachment. An image that nests attachments inside attachments.

fields.png

Side-by-side fields (when short is specified) スクリーンショット 2017-07-01 15.59.15.png

Specification example

"fields": [
    {
        "title": "fields attachment1",
        "value": "fields test",
    },
    {
        "title": "fields attachment2",
        "value": "fields test",
    }
]

short


"fields": [
    {
        "title": "fields attachment1",
        "value": "fields test",
        "short": "true"
    },
    {
        "title": "fields attachment2",
        "value": "fields test",
        "short": "true"
    }
]

image_url

Commentary

Specify the image URL to be embedded in attachment. Supported formats are GIF, JPEG, PNG, BMP

スクリーンショット 2017-07-01 16.12.41.png

Specification example

"image_url": "https://qiita-image-store.s3.amazonaws.com/0/79414/ea00d65c-b9b7-3b97-df98-11d5b2fc6bfa.png ",

thumb_url

Commentary

Specify the thumbnail image URL to be embedded in attachment. Supported formats are GIF, JPEG, PNG, BMP The way the image is displayed is different from ʻimage_url`.

スクリーンショット 2017-07-01 16.18.41.png

Specification example

"thumb_url": "https://qiita-image-store.s3.amazonaws.com/0/79414/741aebb5-d320-4eb1-f765-59d462f32515.png ",

footer

Commentary

A set of parameters for footer information to be embedded in attachment.

footer.png

Specification example

"footer": "Send from Python",
"footer_icon": "https://avatars1.githubusercontent.com/u/10055293?v=3&u=1d1491fc3c27e10e93cc364ee0556a3b768c29b2&s=100",
"ts": "1498894191",

Source

slack API: Attaching content

Recommended Posts

Slack API attachments cheat sheet
Spark API cheat sheet
Curry cheat sheet
SQLite3 cheat sheet
pyenv cheat sheet
conda command cheat sheet
PIL / Pillow cheat sheet
Linux command cheat sheet
ps command cheat sheet
Python3 cheat sheet (basic)
PySpark Cheat Sheet [Python]
Python sort cheat sheet
Go language cheat sheet
tox configuration file cheat sheet
numpy memory reuse cheat sheet
[Python3] Standard input [Cheat sheet]
Data Science Cheat Sheet (Python)
Python Django Tutorial Cheat Sheet
scikit learn algorithm cheat sheet
Apache Beam Cheat Sheet [Python]
Continuation Passing Style (CPS) Cheat Sheet
Python cheat sheet (for C ++ experienced)
Python Computation Library Cheat Sheet ~ itertools ~