AshDispatch.Transports.Discord (AshDispatch v0.1.4)

View Source

Discord webhook transport.

Sends messages to Discord channels via webhooks (async via Oban).

Configuration

Requires webhook_url in channel metadata or via callback:

# Inline configuration
event :order_created,
  channels: [
    [
      transport: :discord,
      audience: :team,
      metadata: [
        webhook_url: "https://discord.com/api/webhooks/..."
      ]
    ]
  ]

# Or via callback module
def channels(context) do
  [
    %Channel{
      transport: :discord,
      audience: :team,
      metadata: %{
        webhook_url: get_discord_webhook_url(:orders)
      }
    }
  ]
end

Content

Discord messages support:

  • notification_message - Simple text content
  • discord_embed - Rich embed with title, description, color, fields
  • discord_username - Override webhook username
  • discord_avatar_url - Override webhook avatar

Example with embed:

content: [
  notification_message: "New order received!",
  discord_embed: %{
    title: "Order {{id}} Created",
    description: "Customer: {{user.name}}",
    color: 5814783,  # Blue color (hex: 58B9FF)
    fields: [
      %{name: "Total", value: "${{total}}", inline: true},
      %{name: "Items", value: "{{item_count}}", inline: true}
    ]
  }
]

Discord Embed Colors

  • Success (Green): 5763719 (0x57F287)
  • Info (Blue): 5814783 (0x58B9FF)
  • Warning (Yellow): 16776960 (0xFFFF00)
  • Error (Red): 15548997 (0xED4245)

Summary

Functions

Delivers Discord notification by enqueueing SendWebhook worker.

Functions

deliver(receipt, context, channel, event_config)

Delivers Discord notification by enqueueing SendWebhook worker.

Receipt Content

Expected content structure:

  • notification_message - Message text (required)
  • discord_embed - Embed object (optional)
  • discord_username - Webhook username override (optional)
  • discord_avatar_url - Webhook avatar override (optional)

Channel Metadata

Expected metadata:

  • webhook_url - Discord webhook URL (required)