@@ -98,6 +98,44 @@ to add some interactive options called `Block elements`_::
9898
9999 $chatter->send($chatMessage);
100100
101+ Adding Fields and Values to a Slack Message
102+ -------------------------------------------
103+
104+ To add fields and values to your message you can use the
105+ :method: `SlackSectionBlock::field() <Symfony\\ Component\\ Notifier\\ Bridge\\ Slack\\ Block\\ SlackSectionBlock::field> ` method::
106+
107+ use Symfony\Component\Notifier\Bridge\Slack\Block\SlackDividerBlock;
108+ use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock;
109+ use Symfony\Component\Notifier\Bridge\Slack\SlackOptions;
110+ use Symfony\Component\Notifier\Message\ChatMessage;
111+
112+ $chatMessage = new ChatMessage('Symfony Feature');
113+
114+ $options = (new SlackOptions())
115+ ->block((new SlackSectionBlock())->text('My message'))
116+ ->block(new SlackDividerBlock())
117+ ->block(
118+ (new SlackSectionBlock())
119+ ->field('*Max Rating*')
120+ ->field('5.0')
121+ ->field('*Min Rating*')
122+ ->field('1.0')
123+ );
124+
125+ // Add the custom options to the chat message and send the message
126+ $chatMessage->options($options);
127+
128+ $chatter->send($chatMessage);
129+
130+ The result will be something like:
131+
132+ .. image :: /_images/notifier/slack/field-method.png
133+ :align: center
134+
135+ .. versionadded :: 5.1
136+
137+ The `field() ` method was introduced in Symfony 5.1.
138+
101139Adding Interactions to a Discord Message
102140----------------------------------------
103141
0 commit comments