Skip to content

Example: Discord Newsletter

Work in Progress

This example is under active development and may change.

This example generates HTML newsletters from Discord channel data. It summarizes messages from each channel, organizes them by category (Share, Introduce Yourself, Geographic Hubs), and formats everything as a weekly newsletter.

Get the code

GitHub

What it demonstrates

  • PipeCondition for conditional routing based on channel name
  • Structured Discord data concepts (messages, attachments, embeds, channels)
  • Channel-specific summarization strategies (new members vs. general)
  • PipeCompose with complex Jinja2 HTML template (filtering, sorting, conditional sections)
  • Custom Python runner for loading external JSON data

The Method: bundle.mthds

Pipeline

[pipe.write_discord_newsletter]
type = "PipeSequence"
inputs = { discord_channel_updates = "DiscordChannelUpdate[]" }
output = "HtmlNewsletter"
steps = [
  { pipe = "summarize_discord_channel_update",
    batch_over = "discord_channel_updates", batch_as = "discord_channel_update",
    result = "channel_summaries" },
  { pipe = "write_weekly_summary", result = "weekly_summary" },
  { pipe = "format_html_newsletter", result = "html_newsletter" },
]

Conditional routing

The summarize_discord_channel_update pipe uses PipeCondition to route different channels to different summarization strategies:

[pipe.summarize_discord_channel_update]
type            = "PipeCondition"
description     = "Select the appropriate summary pipe based on the channel name"
inputs          = { discord_channel_update = "DiscordChannelUpdate" }
output          = "ChannelSummary"
expression      = "discord_channel_update.name"
outcomes        = { "Introduce-Yourself" = "summarize_discord_channel_update_for_new_members" }
default_outcome = "summarize_discord_channel_update_general"

How to run

This example requires a custom Python runner to load Discord channel data from JSON:

cd examples/wip/discord_newsletter
python run_discord_newsletter.py