Eun/sdui-export

★ 0Forks 0GoGitHub ↗Compare

README

sdui-export

CLI tool to export chat messages from Sdui into Markdown or JSON files.

Build

Requires Go 1.22+. If you use mise, the toolchain is managed automatically.

# with mise
mise run build

# or plain go
go build -o sdui-export .

Commands

list-slinks — Find a school's slink

Search for schools by name to discover their slink identifier. No authentication required.

./sdui-export list-slinks <search-term>

Example:

$ ./sdui-export list-slinks basdorf

NAME                                     SLINK                          CITY
---------------------------------------- ------------------------------ --------------------
Grundschule Basdorf                      grundschule-basdorf            Wandlitz
Kindertagesstätte Rappelkiste Basdorf    kindertagesstatte-rappelkis... Wandlitz

Use the SLINK value with --slink when logging in via username/password.


export — Export chat messages

Export all messages from a chat to a Markdown or JSON file.

./sdui-export export [flags]

Authentication

Two mutually exclusive methods:

Method Flags Env vars
Bearer token --token, -t SDUI_TOKEN
Login --user, -u + --password, -p + --slink, -s SDUI_USER, SDUI_PASSWORD, SDUI_SLINK

Token auth:

./sdui-export export --token <TOKEN> --chat-id 12345

Login auth:

./sdui-export export \
  --user myuser \
  --password mypass \
  --slink grundschule-basdorf \
  --chat-id 12345

Use list-slinks to find your school's slink if you don't know it.

Chat selection

Two mutually exclusive options:

Flag Description
--chat-id Numeric chat ID (visible in Sdui URLs)
--chat-name Search by name — case-insensitive substring match against channel name and display name. Fails with a list if multiple chats match.
# by ID
./sdui-export export --token TOKEN --chat-id 12165178

# by name
./sdui-export export --token TOKEN --chat-name "Zielske"

Output format

Flag Values Default
--format markdown, md, json markdown
--output File path chat-<id>.md or chat-<id>.json

Markdown output includes:

  • Title with chat ID
  • Participant list
  • Messages grouped by date, each with author, timestamp, and content (HTML stripped)
  • File attachment links

JSON output structure:

{
  "chat_id": "12165178",
  "exported_at": "2026-06-24T15:30:00Z",
  "total_messages": 71,
  "participants": {
    "995300": "B. Zielske",
    "5599266": "Henriette Salzmann"
  },
  "messages": [
    {
      "uuid": "b21a38e7-...",
      "timestamp": "2026-05-19T16:27:00+02:00",
      "author": "B. Zielske",
      "author_id": 995300,
      "content": "...",
      "type": "MESSAGE"
    }
  ]
}

Time filtering

Both flags are optional and independent.

Flag Description
--start Only include messages at or after this time
--end Only include messages at or before this time

Accepted formats:

2026-01-15
2026-01-15 09:00
2026-01-15 09:00:00
2026-01-15T09:00
2026-01-15T09:00:00+02:00
# messages from June onward
./sdui-export export --token TOKEN --chat-id 123 --start 2026-06-01

# messages in May only
./sdui-export export --token TOKEN --chat-id 123 \
  --start 2026-05-01 --end "2026-05-31 23:59:59"

Full example

# 1. Find your school
./sdui-export list-slinks basdorf

# 2. Export a chat by name, as JSON, filtered to June
./sdui-export export \
  --user myuser \
  --password mypass \
  --slink grundschule-basdorf \
  --chat-name "Zielske" \
  --format json \
  --start 2026-06-01 \
  --end 2026-06-30 \
  --output conversation.json

Environment variables

All auth flags can be set via environment variables to avoid passing secrets on the command line:

export SDUI_TOKEN="eyJ..."
# or
export SDUI_USER="myuser"
export SDUI_PASSWORD="mypass"
export SDUI_SLINK="grundschule-basdorf"

./sdui-export export --chat-name "Zielske"

Development

# run tests
mise run test
# or
go test -v -count=1 ./...

# clean build artifacts
mise run clean

Contributors

Eun

Issues