たまに触ると忘れているのでメモ…
Contents
設定系
ポストごとに送信するチャンネルを変える
{
"channel": "#new_channel",
"text": "テストだよ"
}
ポストごとにbotの表示名を変える
{
"username": "Webhookマン",
"text": "テストだよ"
}
ポストごとにbotのアイコンを変える
{
"icon_emoji": ":bow:",
"text": "テストだよ"
}
※channel
で投稿先を指定していると、チャンネルを削除した時にエラーになるので、あまり使わない方がよさそう
メンション系
ユーザーにメンションを送る
ユーザーにメンションを送る場合は@
で指定するが、「ユーザー名」ではなく「メンバーID」を使用する。
{
"text": "good night <@U01231WAS8J>"
}
@hereや@channel指定をする場合
hereやchannel指定をする場合は@
ではなく!
を使用する。
{
"text": "come on <!here> <!channel>"
}
テキストの装飾について
以前使った時と仕様が変わっていたのでメモ…
細かいカスタマイズができたattachments
についてはlegacyとして非推奨になり、代わりにblocks
を使えとのこと。
An array of legacy secondary attachments. We recommend you use
blocks
instead.
blocks
を使用した装飾についてはBlock Kit Builderという画面上でjsonを確認できるモックページが用意されているので、少し触れば使える機能は大体わかる。

ちなみにblocks
ではcolor
が使えないので、color
使いたい場合はattachments
を併用して使うしかないみたい
There is one exception, and that's the color parameter, which currently does not have a block alternative. If you are strongly attached (🎺) to the color bar, use the blocks parameter within an attachment.