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