@php $flows = $flows ?? collect(); $statusCounts = $statusCounts ?? ['all' => 0, 'live' => 0, 'paused' => 0, 'draft' => 0]; $categoryCounts = $categoryCounts ?? ['all' => 0]; $currentStatus = $currentStatus ?? 'all'; $currentCategory = $currentCategory ?? 'all'; $currentQuery = $currentQuery ?? ''; @endphp
@php $libraryEntries = [ 'all' => ['label' => 'All flows', 'icon' => 'M3 4h10M3 8h10M3 12h6'], 'cart' => ['label' => 'Cart abandonment', 'icon' => 'M3 5h8l1 6H4z'], 'welcome' => [ 'label' => 'Welcome', 'icon' => 'M3 11s2-1 5-1 5 1 5 1M5 6.5h.01M11 6.5h.01M8 9.5s1 .8 0 1.5', ], 'post-purchase' => ['label' => 'Post-purchase', 'icon' => 'M4 13V7l4-4 4 4v6M3 13h10'], 're-engagement' => [ 'label' => 'Re-engagement', 'icon' => 'M11 4H5a3 3 0 0 0 0 6h6a3 3 0 0 1 0 6H5M5 4l-2 2 2 2M11 16l2-2-2-2', ], 'event' => ['label' => 'Special events', 'icon' => 'M2 3h12v11H2zM2 6h12M5 1v3M11 1v3'], 'lead' => [ 'label' => 'Lead nurture', 'icon' => 'M5 6a3 3 0 1 0 0-0.01M2 14c0-3 3-4 6-4s6 1 6 4', ], ]; @endphp
{{ __('Workspace') }} · {{ auth()->user()?->currentWorkspace?->name ?: __('Workspace') }}

{{ __('Automated') }} {{ __('flows') }}.

{{ __('Build reusable WhatsApp workflows — triggered by events, branched by replies, and measured end-to-end.') }}

{{-- Execution history, error logs and retry records for every flow in this workspace. --}} {{ __('Analytics') }} {{-- Opens the builder with the "Generate with AI" modal already open — the builder reads ?ai=1 on mount (useState regex /[?&]ai(_prompt)?=/). Was a dead {{-- Import a flow from an exported .json — auto-submits on file pick. --}}
@csrf
@if ($errors->has('file'))
{{ $errors->first('file') }}
@endif
{{ __('Active flows') }}
{{ $statusCounts['live'] }}
{{ __('running now') }}
{{ __('Total flows') }}
{{ $statusCounts['all'] }}
{{ __('in this workspace') }}
{{ __('Drafts') }}
{{ $statusCounts['draft'] }}
{{ __('unpublished') }}
{{ __('Paused') }}
{{ $statusCounts['paused'] }}
{{ __('temporarily off') }}
@foreach (['all' => 'All flows', 'live' => 'Active', 'paused' => 'Paused', 'draft' => 'Drafts'] as $key => $label) @endforeach
{{-- ===== START FROM A TEMPLATE (admin-curated) ===== --}} @if (isset($flowTemplates) && count($flowTemplates)) @php $tplTypeBadge = [ 'chat' => ['Chat', 'bg-wa-mint text-wa-deep'], 'call' => ['Call', 'bg-accent-amber/15 text-[#7B5A14]'], 'instagram' => ['Instagram', 'bg-[#EFE5F5] text-[#5B3D8A]'], ]; @endphp
{{ __('Starter templates') }}

{{ __('Start from a template') }}

@foreach ($flowTemplates as $tpl) @php $tb = $tplTypeBadge[$tpl->flow_type] ?? ['—', 'bg-paper-100 text-ink-500']; @endphp
{{ $tpl->name }} {{ $tb[0] }}

{{ $tpl->description ?: __('A ready-made flow you can customise.') }}

{{ $tpl->node_count }} {{ __('steps') }}@if ($tpl->category) · {{ $tpl->category }}@endif
@csrf
@endforeach
@endif {{-- $igConnected is true ONLY in REMOTE-Instaflow mode: the native addon leaves $instaflowUrl null (its flows are flow_type=instagram rows already in the grid below, each with an Instagram badge from _cards). So this whole remote panel + tabs shows only when a SEPARATE Instaflow deployment is connected. --}} @php $igConnected = isset($instaflowUrl) && $instaflowUrl; @endphp {{-- Channel tabs — switch the flow list between WhatsApp and Instagram. Only shown when a remote Instaflow is connected; otherwise the grid renders on its own as before. --}} @if ($igConnected)
@endif @if ($igConnected)
{{-- Slim heading shown on the "All" tab — the full banner below is heavy for a mid-page divider, so on All we collapse it to a compact label (Fetch / Open builder live on the dedicated Instagram tab). --}}

{{ __('Instagram flows') }}

{{ count($instagramFlows) }}
@if (!empty($instagramFlows))
@foreach ($instagramFlows as $igf) @php $igfName = is_array($igf) ? ($igf['name'] ?? 'Instagram flow') : ($igf->name ?? 'Instagram flow'); $igfId = is_array($igf) ? ($igf['id'] ?? null) : ($igf->id ?? null); @endphp {{-- Same shape as the WhatsApp .flow-card, in Instagram pink. --}}
{{ __('Instagram') }}
{{ $igfName }}

{{ __('Instagram DM automation running on your connected account.') }}

  • {{ __('Runs on Instagram') }}
  • {{ __('Edited in the Instagram builder') }}
  • @if ($igfId !== null)
  • {{ __('Flow') }} #{{ $igfId }}
  • @endif
{{-- Edit inside WaDesk's own builder: imports the flow's full node data from Instaflow, opens it here, and rounds-trips back to the same Instaflow flow on save. --}} @if ($igfId !== null) {{ __('Edit flow') }} @endif
@endforeach
@else {{-- Connected, but no flows yet (or Instaflow was unreachable). --}}

{{ __('No Instagram flows found yet. Build one in the Instagram builder, then click Fetch flows.') }}

@endif
@endif
@include('user.flows._cards', ['flows' => $flows])
@include('user.partials.pagination', [ 'paginator' => $flows, 'dataAttr' => 'data-fl-page', 'label' => 'flows', ])
{{ __('Help · 01') }}
{{ __('What is an automated workflow?') }}

{{ __('A sequence of messages, waits, and decision branches that starts from a trigger like signup, cart abandonment, or purchase completion.') }}

{{ __('Help · 02') }}
{{ __('How do I optimize my flows?') }}

{{ __('Keep the opening step short, branch by intent early, and measure drop-off at each node so you know where conversion slips.') }}

{{ __('Help · 03') }}
{{ __('Which flows should I launch first?') }}

{{ __('For most stores: welcome → cart recovery → post-purchase review. That covers acquisition, conversion, and retention with minimum overhead.') }}

{{-- ── Channel picker ────────────────────────────────────────────── Replaces the old "blank / call / instagram" button row. The builder is one canvas; the channel only decides which node palette it shows (data-flow-type → nodeInMode in the builder JS) and which flow_type is persisted on save. Opened by [data-flow-create]; wired in resources/js/charts/user-flows-index.js --}}