A single-binary, config-driven notification CLI. One tool, any channel: email (SMTP and SMTP-compatible providers), Slack/Discord/Teams webhooks, SMS gateways, push services, arbitrary API calls, and anything else via a local command escape hatch.
echo "deploy finished" | noty --channel slack
noty -m "disk 92% full" --channel email,sms --to +15551234567
noty -m "release v2.4" --var environment=prod --dry-run
go install github.com/suprbdev/noty@latest
or from a checkout:
go build -o noty .
- YAML config defines named channels. Each channel has a
type(the connection/provider) plus provider-specific settings. - Three provider types cover everything:
smtp— email, including SES/SendGrid/Mailgun/Postmark SMTP endpoints.http— webhooks, REST APIs, SMS gateways (Twilio-style form posts), push services (Pushover, ntfy, Gotify), PagerDuty, etc. URL, headers, form fields, and body are all templates.exec— escape hatch: run any local command (vendor CLIs likeaws sns publish,signal-cli, custom scripts). Body is piped to stdin, args are templates.
- Secrets stay in the environment. Use
${VAR}anywhere in the config; loading fails loudly if a variable is unset.${VAR:-default}allows a fallback,$$escapes a literal dollar.--dry-runoutput and error messages show values substituted via${VAR}(4+ bytes, raw or URL-escaped) as${VAR}, and header/query/form fields named like credentials asREDACTED. Values read with theenvtemplate function are not masked. - Templates live outside the binary as plain files (Go
text/templatesyntax), resolved relative totemplate_dir, or inline in the config.
--config PATH → $NOTY_CONFIG → ~/.config/noty/config.yaml (or
.yml) → /etc/noty/config.yaml
The current directory is never searched: a config can run exec
commands, so a checked-out repo must not be able to supply one. Use
-c ./noty.yaml for a project-local file.
See noty.example.yaml for a full example with eight channels.
Message text: --message flag, else piped stdin. With neither, noty refuses
to run from an interactive terminal (-m '' sends an empty message);
stdin of /dev/null, as under cron or systemd, is an empty message.
Body: --template FILE flag → channel body_template (file) → channel
body (inline) → raw message text.
Subject: the base subject is --subject, else defaults.subject (a
template). A channel subject_template / subject renders with the base as
{{ .Subject }} (e.g. "[prod] {{ .Subject }}"); without one the base is
used as is.
Template variables merge in order: global vars → channel vars →
--var key=value flags (repeatable, later wins).
| Field | Meaning |
|---|---|
{{ .Message }} |
raw message text |
{{ .Subject }} |
resolved subject (the base subject inside a channel subject template) |
{{ .To }} |
recipients from --to ({{ index .To 0 }} for the first) |
{{ .Channel }} |
channel name |
{{ .Vars.key }} |
merged variables |
{{ .Now }} |
send time ({{ timefmt "15:04" .Now }}) |
{{ .Hostname }} |
sending host |
Functions: json (safe JSON encoding — always use it when building JSON
payloads), upper, lower, title, trim, replace, join, split,
contains, default, urlquery, truncate, timefmt, env, plus the
text/template builtins (html for escaping into HTML bodies, printf,
index, ...).
Referencing an undefined variable is an error, so typos fail loudly. For an
optional variable use index, which yields "" when the key is absent:
{{ default "general" (index .Vars "topic") }}.
-c, --config config file path
--channel channel name(s), comma-separated for fan-out
-m, --message message text (else stdin)
-s, --subject subject override
-t, --template body template file override
--to recipient override (repeatable)
-v, --var key=value template variable (repeatable)
--timeout per-attempt send timeout (default 30s or defaults.timeout)
--retries retry temporary failures N times (default: channel or defaults.retries)
--dry-run render and print what would be sent (secrets redacted)
--list list configured channels
--verbose verbose output
--version print version and exit
Fan-out channels are sent concurrently; output is reported in --channel
order. Exit code is non-zero if any channel fails; failures on one channel
don't stop the others.
retries (under defaults or per channel; --retries overrides both,
default 0) retries failures that normally mean nothing was delivered:
connection failures, HTTP 429/502/503/504 and SMTP 4xx replies. Timeouts
after a request was sent, HTTP 500 and exec failures are never retried,
since the notification may already have gone out. Backoff doubles from 1s
up to 30s, and each attempt gets the full timeout. HTTP redirects to another
host or from https to http are refused, since they would forward headers
and the body.
github.com/suprbdev/noty/notify sends notifications from a Go program
with the same config format, templates, fan-out, retries and secret masking
as the CLI (which is built on it):
go get github.com/suprbdev/noty@latest
cfg, err := notify.Load("/etc/myapp/noty.yaml") // or notify.Parse(data)
if err != nil {
return err // errors.Is(err, notify.ErrInvalidConfig) for config problems
}
client, err := notify.New(cfg)
if err != nil {
return err
}
res, err := client.Send(ctx, notify.Message{
Channels: []string{"slack", "email"}, // empty: defaults.channel
Subject: "deploy finished",
Text: "api v2.4 is live", // {{ .Message }}
Vars: map[string]string{"environment": "prod"},
})
var sendErr *notify.SendError
if errors.As(err, &sendErr) {
// Some channels failed; the others were still attempted.
log.Printf("failed channels %v: %v", res.Failed(), err)
}Message also has To (recipient override), Template (body template
file override) and DryRun (render and validate only; each
ChannelResult.Description says what would be sent). Send returns
notify.ErrNoChannel or an error wrapping notify.ErrUnknownChannel
before sending anything when the channels can't be resolved.
Options: notify.WithLookupEnv resolves ${VAR} through your own lookup
instead of the process environment (for Load/Parse); WithHTTPClient,
WithExecRunner (fake or restrict exec channels), WithTimeout,
WithRetries, WithBackoff and WithClock customise the client.
Implement the Sender interface and register a factory — nothing else
changes:
// internal/provider/carrierpigeon.go
func init() {
Register("pigeon", func(node *yaml.Node, deps Deps) (Sender, error) {
var cfg pigeonConfig
if err := Decode(node, "pigeon", &cfg); err != nil { return nil, err }
return &pigeonSender{cfg}, nil
})
}Each provider decodes its own YAML from the channel node, so new settings
never touch the core config code. deps.Renderer templates the provider's
own fields. Decode rejects keys that are neither
provider fields nor common channel fields, so config typos fail loudly with
a line number.
# Pipe a log tail to the default channel
tail -20 app.log | noty -s "app errors"
# SMS a specific number (Twilio-style channel)
noty --channel sms --to +15551234567 -m "Server db-1 unreachable"
# ntfy push to a topic chosen at send time
noty --channel ntfy --var topic=alerts -m "backup done"
# Fan out to email + Slack with a custom template and staging vars
noty --channel email,slack -t incident.tmpl \
--var environment=staging --var severity=high \
-m "Elevated 5xx rate on api-gateway"
# Preview exactly what would be sent (auth headers redacted)
noty --channel api -m test --dry-run