-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Notifier] Docs for Slack options field() method #15198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,44 @@ to add some interactive options called `Block elements`_:: | |
|
||
$chatter->send($chatMessage); | ||
|
||
Adding Fields and Values to a Slack Message | ||
------------------------------------------- | ||
|
||
To add fields and values to your message you can use the | ||
:method:`SlackSectionBlock::field() <Symfony\\Component\\Notifier\\Bridge\\Slack\\Block\\SlackSectionBlock::field>` method:: | ||
|
||
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackDividerBlock; | ||
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock; | ||
use Symfony\Component\Notifier\Bridge\Slack\SlackOptions; | ||
use Symfony\Component\Notifier\Message\ChatMessage; | ||
|
||
$chatMessage = new ChatMessage('Symfony Feature'); | ||
|
||
$options = (new SlackOptions()) | ||
->block((new SlackSectionBlock())->text('My message')) | ||
->block(new SlackDividerBlock()) | ||
->block( | ||
(new SlackSectionBlock()) | ||
->field('*Max Rating*') | ||
->field('5.0') | ||
->field('*Min Rating*') | ||
->field('1.0') | ||
); | ||
|
||
// Add the custom options to the chat message and send the message | ||
$chatMessage->options($options); | ||
|
||
$chatter->send($chatMessage); | ||
|
||
The result will be something like: | ||
|
||
.. image:: /_images/notifier/slack/field-method.png | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure an image is needed here ... the feature is easy to understand ... and this image will be outdated as soon as Slack makes any visual change in their app (which is common). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree but decided to add it because its not clear "how" the are displayed, because you add them in procedural way but its rendered like "table" If you want, feel free to remove it while merging |
||
:align: center | ||
|
||
.. versionadded:: 5.1 | ||
|
||
The `field()` method was introduced in Symfony 5.1. | ||
OskarStark marked this conversation as resolved.
Show resolved
Hide resolved
OskarStark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Adding Interactions to a Discord Message | ||
---------------------------------------- | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.