# Webhook → Slack: the boring n8n parity demo, ported.
#
# Boots an axum server on port 8090. First POST to /alert is shaped
# into a Slack message and posted to the configured channel. Workflow
# exits after the message lands.
#
# Setup (one-time, in ~/.flow/credentials.toml):
#
#   [slack]
#   token = "xoxb-your-bot-token"
#
# Run:
#   r8r run examples/webhook-to-slack.toml
#
# Trigger:
#   curl -X POST -H 'content-type: application/json' \
#     -d '{"severity": "alert", "host": "fw01", "msg": "ssh: auth failure x12"}' \
#     http://localhost:8090/alert
#
# Compare to n8n: same workflow needs ~300MB of Node + a Postgres + the
# Vue editor running. This is a 14-line TOML and an 8MB binary.

[workflow]
name = "webhook-to-slack"
version = 1

[[nodes]]
name = "Webhook"
type = "webhook"
[nodes.parameters]
port = 8090
path = "/alert"

[[nodes]]
name = "Shape"
type = "set"
[nodes.parameters]
fields = { channel = "#alerts", text = "[{{ $json.severity }}] {{ $json.host }}: {{ $json.msg }}" }

[[nodes]]
name = "Slack"
type = "slack"
credentials = "slack"
[nodes.parameters]
operation = "post_message"
channel = "{{ $json.channel }}"
text = "{{ $json.text }}"

[[edges]]
from = "Webhook"
to = "Shape"

[[edges]]
from = "Shape"
to = "Slack"
