SlackMessage
class SlackMessage implements Arrayable
Traits
Properties
| protected string|null | $channel | The channel to send the message on. |
|
| protected string|null | $text | The text content of the message. |
|
| protected array<mixed[]|BlockContract> | $blocks | The message's blocks. |
|
| protected string|null | $icon | The user emoji icon for the message. |
|
| protected string|null | $image | The user image icon for the message. |
|
| protected EventMetadata|null | $metaData | The JSON metadata for the message. |
|
| protected bool|null | $mrkdwn | Indicates if you want the message to parse markdown or not. |
|
| protected bool|null | $unfurlLinks | Indicates if you want a preview of links inlined in the message. |
|
| protected bool|null | $unfurlMedia | Indicates if you want a preview of links to media inlined in the message. |
|
| protected string|null | $username | The username to send the message as. |
|
| protected string|null | $threadTs | Unique, per-channel, timestamp for each message. If provided, send message as a thread reply to this message. |
|
| protected bool|null | $broadcastReply | If sending message as reply to thread, whether to 'broadcast' a reference to the thread reply to the parent conversation. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Set the Slack channel the message should be sent to.
Set the fallback and notification text of the Slack message.
Add a new Divider block to the message.
Add a new Image block to the message.
Set a custom image icon the message should use.
Set a custom image icon the message should use.
Set the metadata the message should include.
Disable Slack's markup parsing.
Unfurl links for rich display.
Unfurl media for rich display.
Set the user name for the Slack bot.
Set the thread timestamp (message ID) to send as reply to thread.
Only applicable if threadTimestamp is set. Broadcasts a reference to the threaded reply to the parent conversation.
Specify a raw Block Kit Builder JSON payload for the message.
Get the instance as an array.
Dump the payload as a URL to the Slack Block Kit Builder.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
at line 90
SlackMessage
to(string $channel)
Set the Slack channel the message should be sent to.
at line 100
SlackMessage
text(string $text)
Set the fallback and notification text of the Slack message.
at line 110
SlackMessage
actionsBlock(Closure $callback)
Add a new Actions block to the message.
at line 122
SlackMessage
contextBlock(Closure $callback)
Add a new Context block to the message.
at line 134
SlackMessage
dividerBlock()
Add a new Divider block to the message.
at line 144
SlackMessage
headerBlock(string $text, Closure|null $callback = null)
Add a new Header block to the message.
at line 154
SlackMessage
imageBlock(string $url, Closure|string|null $altText = null, Closure|null $callback = null)
Add a new Image block to the message.
at line 173
SlackMessage
sectionBlock(Closure $callback)
Add a new Section block to the message.
at line 185
SlackMessage
emoji(string $emoji)
Set a custom image icon the message should use.
at line 196
SlackMessage
image(string $image)
Set a custom image icon the message should use.
at line 207
SlackMessage
metadata(string $eventType, array $payload = [])
Set the metadata the message should include.
at line 217
SlackMessage
disableMarkdownParsing()
Disable Slack's markup parsing.
at line 227
SlackMessage
unfurlLinks(bool $unfurlLinks = true)
Unfurl links for rich display.
at line 237
SlackMessage
unfurlMedia(bool $unfurlMedia = true)
Unfurl media for rich display.
at line 247
SlackMessage
username(string $username)
Set the user name for the Slack bot.
at line 257
SlackMessage
threadTimestamp(string|null $threadTimestamp)
Set the thread timestamp (message ID) to send as reply to thread.
at line 267
SlackMessage
broadcastReply(bool|null $broadcastReply = true)
Only applicable if threadTimestamp is set. Broadcasts a reference to the threaded reply to the parent conversation.
at line 280
SlackMessage
usingBlockKitTemplate(string $template)
Specify a raw Block Kit Builder JSON payload for the message.
at line 296
array
toArray()
Get the instance as an array.
at line 328
dd(bool $raw = false)
Dump the payload as a URL to the Slack Block Kit Builder.