AshDispatch.Transports.Slack (AshDispatch v0.1.4)
View SourceSlack webhook transport.
Sends messages to Slack channels via webhooks (async via Oban).
Configuration
Requires webhook_url in channel metadata or via callback:
# Inline configuration
event :order_created,
channels: [
[
transport: :slack,
audience: :team,
metadata: [
webhook_url: "https://hooks.slack.com/services/..."
]
]
]
# Or via callback module
def channels(context) do
[
%Channel{
transport: :slack,
audience: :team,
metadata: %{
webhook_url: get_slack_webhook_url(:orders)
}
}
]
endContent
Slack messages support:
notification_message- Simple text content (supports Slack mrkdwn)slack_blocks- Block Kit layout blocks for rich formattingslack_attachments- Legacy attachment formatslack_username- Override bot usernameslack_icon_emoji- Override bot icon with emojislack_icon_url- Override bot icon with image URL
Example with blocks:
content: [
notification_message: "New order received!",
slack_blocks: [
%{
type: "header",
text: %{type: "plain_text", text: "Order {{id}} Created"}
},
%{
type: "section",
fields: [
%{type: "mrkdwn", text: "*Customer:*\n{{user.name}}"},
%{type: "mrkdwn", text: "*Total:*\n${{total}}"}
]
}
]
]Slack Message Formatting
Slack uses mrkdwn (markdown-like) formatting:
*bold*- Bold text_italic_- Italic text~strikethrough~- Strikethrough`code`- Inline codecode block- Code block<url|text>- Hyperlink
Summary
Functions
Delivers Slack notification by enqueueing SendWebhook worker.
Functions
Delivers Slack notification by enqueueing SendWebhook worker.
Receipt Content
Expected content structure:
notification_message- Message text (required, supports mrkdwn)slack_blocks- Block Kit blocks (optional)slack_attachments- Legacy attachments (optional)slack_username- Bot username override (optional)slack_icon_emoji- Bot icon emoji (optional, e.g., ":robot_face:")slack_icon_url- Bot icon URL (optional)
Channel Metadata
Expected metadata:
webhook_url- Slack webhook URL (required)