{
  "name": "Decision Spinner",
  "description": "Type a list of options and let the workflow pick one at random for you.",
  "tags": [
    "random",
    "picker",
    "decision",
    "fun",
    "choice",
    "spinner"
  ],
  "type": "triggered",
  "nodes": [
    {
      "id": "sticky-intro",
      "position": {
        "x": 20,
        "y": 20
      },
      "data": {
        "color": "#fff266",
        "content": "🎲 Can't decide? Let chance pick.\n\nPress Run and enter your options (one per line, or separated by commas). The flow picks one at random. Nothing to connect."
      },
      "type": "stickyNote",
      "width": 360,
      "height": 190
    },
    {
      "id": "trigger-run",
      "position": {
        "x": 100,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:trigger:whenStarted"
        },
        "label": "Run now",
        "inputs": {},
        "parameters": {
          "notes": "Starts the workflow when you press Run."
        }
      },
      "type": "trigger"
    },
    {
      "id": "options-form",
      "position": {
        "x": 420,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:inPageForm:inPageForm"
        },
        "label": "Enter options",
        "inputs": {
          "title": "What should I pick from?",
          "fields": [
            {
              "name": "options",
              "label": "Options (one per line or comma-separated)",
              "type": "textarea",
              "required": true
            }
          ]
        },
        "parameters": {
          "notes": "Collects the list of choices as free text."
        }
      },
      "type": "inPageForm"
    },
    {
      "id": "split-options",
      "position": {
        "x": 740,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:text-formatter"
        },
        "label": "Split into lines",
        "inputs": {
          "operation": "split",
          "text": "{{ $input.options }}",
          "separator": "\n"
        },
        "parameters": {
          "notes": "Breaks the text into a rough list of lines before the code cleans it up."
        }
      },
      "type": "basic"
    },
    {
      "id": "pick-one",
      "position": {
        "x": 1060,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:code"
        },
        "label": "Pick a winner",
        "inputs": {
          "code": "import random\nitems = input.get('result', input) if isinstance(input, dict) else input\nif isinstance(items, str):\n    items = [items]\nif not isinstance(items, list):\n    items = [items]\nopts = []\nfor it in items:\n    for part in str(it).replace(',', '\\n').split('\\n'):\n        p = part.strip()\n        if p:\n            opts.append(p)\nif not opts:\n    opts = ['(no options provided)']\nout = {'pick': random.choice(opts), 'options': opts, 'count': len(opts)}\nout"
        },
        "parameters": {
          "notes": "Cleans the list (splitting on commas and newlines) and picks one option at random with Python."
        }
      },
      "type": "basic"
    },
    {
      "id": "show-result",
      "position": {
        "x": 1380,
        "y": 300
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:displayMarkdownNode"
        },
        "label": "Show the winner",
        "inputs": {
          "title": "The spinner says…",
          "content": "## 🎲 The spinner says…\n\n# {{ $input.result.pick }}\n\nPicked at random from {{ $input.result.count }} option(s)."
        },
        "parameters": {
          "notes": "Announces the randomly chosen option."
        }
      },
      "type": "basic"
    }
  ],
  "edges": [
    {
      "id": "e-run-form",
      "type": "flowEdge",
      "source": "trigger-run",
      "target": "options-form"
    },
    {
      "id": "e-form-split",
      "type": "flowEdge",
      "source": "options-form",
      "target": "split-options"
    },
    {
      "id": "e-split-pick",
      "type": "flowEdge",
      "source": "split-options",
      "target": "pick-one"
    },
    {
      "id": "e-pick-show",
      "type": "flowEdge",
      "source": "pick-one",
      "target": "show-result"
    }
  ]
}