@php // Channel Settings hub. The page renders in TWO modes: // • landing (no {section}) → a card grid, one card per channel/area. // • detail ({section}) → the full settings form with only the // picked section visible; every OTHER section stays in the DOM // (CSS-hidden) so the SINGLE whole-form save still submits every // field and can never wipe another channel's creds. The save // handler (settingsProvidersUpdate) is unchanged. $section = $section ?? null; // Card registry. `on` is the status pill; `svg` is the inner of a // 16-viewport icon unless it starts with a full '' . \App\Support\SvgIcon::inner('brands', $n) . ''; $lucideSvg = fn ($n) => '' . \App\Support\SvgIcon::inner('lucide', $n) . ''; $svgThreads = $brandSvg('threads'); $svgLinkedin = $brandSvg('linkedin'); $svgX = $brandSvg('x'); $svgWhatsapp = $brandSvg('whatsapp'); $svgFacebook = $brandSvg('facebook'); $svgTelegram = $brandSvg('telegram'); $svgTiktok = $brandSvg('tiktok'); $svgInstagram = $brandSvg('instagram'); $svgLine = $brandSvg('line'); $svgWechat = $brandSvg('wechat'); $svgViber = $brandSvg('viber'); $svgSms = $lucideSvg('message-square-text'); $svgEmail = $lucideSvg('mail'); $cards = [ 'whatsapp' => ['tag' => 'messaging', 'title' => __('WhatsApp'), 'on' => true, 'onLabel' => count($settings['allowed_send_methods'] ?? []) . ' ' . __('engine(s)'), 'bg' => '#25D366', 'svg' => $svgWhatsapp, 'desc' => __('WhatsApp engines (Unofficial · Business API · Twilio), Meta app credentials, coexistence, multi-tenant routing — plus Meta templates, registration OTP, sender pacing and campaign auto-end.')], 'facebook' => ['tag' => 'channel', 'title' => __('Facebook Pages'), 'on' => $fbOn, 'onLabel' => $fbOn ? __('Enabled') : __('Disabled'), 'bg' => '#1877F2', 'svg' => $svgFacebook, 'desc' => __('Reuses the WhatsApp Meta app — one toggle to let workspaces connect Pages, comments and Messenger.')], 'telegram' => ['tag' => 'channel', 'title' => __('Telegram'), 'on' => $tgOn, 'onLabel' => $tgOn ? __('Enabled') : __('Disabled'), 'bg' => '#229ED9', 'svg' => $svgTelegram, 'desc' => __('Bot API — no OAuth. Paste-a-token connect, plus optional API id/hash for the in-app bot maker.')], 'line' => ['tag' => 'channel', 'title' => __('LINE'), 'on' => $lineOn, 'onLabel' => $lineOn ? __('Enabled') : __('Disabled'), 'bg' => '#06C755', 'svg' => $svgLine, 'desc' => __('LINE Messaging API — paste a channel access token + secret. Big in Japan, Taiwan and Thailand.')], 'wechat' => ['tag' => 'channel', 'title' => __('WeChat'), 'on' => $wechatOn, 'onLabel' => $wechatOn ? __('Enabled') : __('Disabled'), 'bg' => '#07C160', 'svg' => $svgWechat, 'desc' => __('WeChat Official Account — paste AppID + AppSecret + Token. A certified Service Account is required.')], 'viber' => ['tag' => 'channel', 'title' => __('Viber'), 'on' => $viberOn, 'onLabel' => $viberOn ? __('Enabled') : __('Disabled'), 'bg' => '#7360F2', 'svg' => $svgViber, 'desc' => __('Viber Public Account — paste the bot auth token. Users must open a chat with the bot before you can message them.')], 'tiktok' => ['tag' => 'channel', 'title' => __('TikTok'), 'on' => $ttOn, 'onLabel' => $ttOn ? __('Enabled') : __('Disabled'), 'bg' => '#010101', 'svg' => $svgTiktok, 'desc' => __('Separate TikTok for Developers app — client key/secret, plus Business Messaging and TikTok Shop.')], 'sms' => ['tag' => 'channel', 'title' => __('SMS'), 'on' => $smsOn,'onLabel' => $smsOn ? __('Enabled') : __('Disabled'), 'bg' => '#0EA5E9', 'svg' => $svgSms, 'desc' => __('Multi-gateway SMS channel (Twilio, Vonage, Plivo, MessageBird, Sinch, Telnyx, MSG91). Connect numbers per workspace or set platform keys.')], 'email' => ['tag' => 'channel', 'title' => __('Email'), 'on' => $emailOn, 'onLabel' => $emailOn ? __('Enabled') : __('Disabled'), 'bg' => '#6366F1', 'svg' => $svgEmail, 'desc' => __('Email inbox via the linked :brand install — inbound mail lands in the team inbox and replies send from the connected mailbox.', ['brand' => mailtrixy_brand_name()])], ]; // Threads (Meta) — a core publishing channel with its OWN settings page // (/admin/settings/threads), so it appears here as a card that links out. $cards['threads'] = [ 'tag' => 'channel', 'title' => __('Threads'), 'on' => $thOn, 'onLabel' => $thOn ? __('Enabled') : __('Disabled'), 'desc' => __('Publish and schedule text, image, video and carousel posts to Threads from the social calendar.'), 'href' => url('/admin/settings/threads'), 'bg' => '#000000', 'svg' => $svgThreads, ]; // LinkedIn — a core publishing channel with its OWN settings page // (/admin/settings/linkedin). Publishing only (no LinkedIn messaging API). $cards['linkedin'] = [ 'tag' => 'channel', 'title' => __('LinkedIn'), 'on' => $liOn, 'onLabel' => $liOn ? __('Enabled') : __('Disabled'), 'desc' => __('Publish and schedule text, image, video and link posts to a LinkedIn profile or Company Page from the social calendar.'), 'href' => url('/admin/settings/linkedin'), 'bg' => '#0A66C2', 'svg' => $svgLinkedin, ]; // X (Twitter) — a core publishing channel with its OWN settings page // (/admin/settings/x). Pay-per-use, BYO-app. Publishing only. $cards['x'] = [ 'tag' => 'channel', 'title' => __('X (Twitter)'), 'on' => $xOn, 'onLabel' => $xOn ? __('Enabled') : __('Disabled'), 'desc' => __('Publish and schedule posts to X from the social calendar. Pay-per-use API — workspaces connect their own X keys.'), 'href' => url('/admin/settings/x'), 'bg' => '#000000', 'svg' => $svgX, ]; // Instagram is an installed add-on that used to sit in the sidebar. It // has its OWN settings page (/admin/settings/instagram), so it appears // here as a card linking out — pulled from the extension's admin nav so // it only shows when the add-on is active, and follows its real href/icon. $igNav = collect(\App\Services\ExtensionRegistry::nav('admin'))->firstWhere('key', 'instagram'); if ($igNav) { $cards['instagram'] = [ 'tag' => 'channel', 'title' => __('Instagram'), 'on' => true, 'onLabel' => __('Add-on'), 'desc' => __('Direct messages, story replies, comments and posts — connect Instagram accounts and run them in the unified inbox.'), 'href' => $igNav['href'], 'bg' => 'linear-gradient(45deg,#F58529,#DD2A7B 55%,#8134AF)', 'svg' => $svgInstagram, ]; } // Title shown on a detail page. $secTitle = $section && isset($cards[$section]) ? $cards[$section]['title'] : null; @endphp
{{ __('Admin') }} {{ __('Settings') }} @if ($section) {{ __('Channels') }} {{ $secTitle ?? __('Channel') }} @else {{ __('Channel Settings') }} @endif
{{ __('Admin - Channel settings') }}
@if ($section)

{{ $secTitle ?? __('Channel') }} {{ __('settings') }}.

{{ __('Configure this channel below. The global Node bridge is shown at the top of the page — every other channel keeps its own saved values.') }}

@else

{{ __('Channel') }} {{ __('settings') }}.

{{ __('Every messaging channel and sending control on the platform. Pick a card to open its own page and put in the connection details.') }}

@endif
@if ($section) {{ __('All channels') }} @else {{ __('All settings') }} @endif
@if (!$section) {{-- ===== GLOBAL Node bridge — NOT a card. The shared Node bridge every engine talks to (Unofficial sends + pacing run through it). Saved by its OWN lightweight endpoint (node.update) so it never touches the per-channel provider form, with a live Test-connection ping. ===== --}}
{{ __('global · node bridge') }}

{{ __('Node bridge URL & token') }}

{{ __('The shared Node bridge every engine talks to — the Unofficial API sends through it and sender pacing is applied here. Set once; it applies platform-wide.') }}

{{ ($settings['node_webhook_token_set'] ?? false) ? __('Token set') : __('No token') }}
@csrf
{{-- ===== LANDING: card grid (like /admin/settings) ===== --}}
@foreach ($cards as $slug => $c)
@if (!empty($c['svg'])) {!! $c['svg'] !!} @else {!! $c['icon'] ?? '' !!} @endif {{ $c['onLabel'] }}
{{ $c['tag'] }}

{{ $c['title'] }}

{{ $c['desc'] }}

{{ __('Open') }}
@endforeach
@else {{-- ===== DETAIL: full form, only $section visible ===== --}} {{-- The actual
; existing card UI lives inside it. The "Save changes" button at the page header submits via the form="wadesk-providers-form" attribute. --}} @csrf {{-- Return to THIS channel page after the whole-form save. --}}
@php // Multi-engine: the platform-enabled set drives which provider cred // panes render. NOTE: channel sections are NO LONGER gated on WABA // being enabled — every channel gets its own page in the hub. $allowedEngines = $settings['allowed_send_methods'] ?? ['baileys']; $allowedEngines = is_array($allowedEngines) ? $allowedEngines : [$allowedEngines]; @endphp {{-- The Node bridge (URL + token) is edited on the hub landing (global panel), NOT here. But the whole-form save unconditionally writes baileys_server_url, so we carry the current values as HIDDEN inputs to preserve them when saving any channel. The token stays EMPTY (the save keeps the stored one when the field is blank). --}}
$section === 'whatsapp'])>
{{-- ===== WHATSAPP (multi-tenant dispatch — part of the WhatsApp page) ===== --}}
$section !== 'whatsapp'])>
{{ __('waba · multi-tenant dispatch') }}

{{ __('Per-workspace WABA routing') }}

Routes every outbound /chat send through the workspace's own connected WABA account instead of a single shared platform token. Required for multi-merchant production. Default {{ __('OFF') }} so existing installs keep using the legacy single-tenant path.

{{ __('Connected WABAs') }}
{{ number_format($settings['waba_connected_count']) }}
{{ __('across all workspaces') }}
@if ($settings['waba_dispatch_v2_enabled'] && $settings['waba_connected_count'] === 0)
{{ __('Warning:') }} v2 is enabled but no workspace has connected a WABA at /devices yet. Outbound sends will return "No connected WABA account" until at least one workspace connects.
@endif
{{-- /whatsapp dispatch --}} {{-- ===== FACEBOOK ===== --}}
$section !== 'facebook'])> {{-- Facebook Pages channel — same Meta app, one toggle. --}}
{{ __('channel') }}

{{ __('Facebook Pages') }}

{{ __('Uses this same Meta app — nothing else to configure. Turn it on and workspaces connect their Facebook account (all its Pages) from Channels to publish posts, reply to comments and run Messenger in the inbox.') }} {{ __('Webhook callback:') }} {{ url('/webhooks/facebook') }}

{{-- What / why --}}
{{ __('What it is') }}

{{ __('One toggle that turns on the Facebook Pages channel. Workspaces then connect their Facebook account (all its Pages) and manage Page posts, comment replies and Messenger DMs inside the unified inbox.') }}

{{ __('Why it needs nothing extra') }}

{{ __('It reuses the SAME Meta app as WhatsApp Business API — the App ID + Secret you set on the WhatsApp page. No second app, no separate keys. You only add the Messenger + Webhooks products and permissions to that one app.') }}

{{-- Connect mode switch: ON = each workspace connects FB/IG with its OWN Meta app (Settings → Meta app: App ID + Secret + paste a token). Use this while THIS platform app is still in Meta review. OFF = workspaces connect through THIS platform app ("Continue with Facebook"). Needs this app fully approved. --}}
{{ __('Clients use their OWN Meta app (manual keys + token)') }}

{{ __('ON: each workspace pastes its OWN App ID + App Secret and a Page/Instagram token to connect (webhook auto-configured). Best while this platform app is in Meta App Review. OFF: workspaces connect through this platform app with "Continue with Facebook" (needs this app fully approved by Meta). One switch covers both Facebook and Instagram.') }}

{{-- Setup steps --}}
{{ __('Set-up steps (one-time, on your Meta app)') }}
  1. {{ __('Open') }} developers.facebook.com/apps → {{ __('your app (the one with the App ID + Secret already on the WhatsApp page).') }}
  2. {{ __('Add products:') }} {{ __('Messenger') }}, {{ __('Facebook Login') }} {{ __('and') }} {{ __('Webhooks') }}.
  3. {{ __('In Messenger → Settings → Webhooks (or Webhooks → Page), set the callback URL + verify token below and subscribe the fields listed.') }}
  4. {{ __('Request these permissions, then submit for App Review to go live:') }} pages_show_list, pages_messaging, pages_manage_metadata, pages_read_engagement, pages_manage_posts, pages_read_user_content.
  5. {{ __('Turn the toggle above ON. Workspaces with the Facebook plan feature then connect their account from Channels — no keys to paste on their end.') }}
{{ __('Latest:') }} {{ __('the Graph API version used for calls is set on the WhatsApp page (default v23.0). Messenger + Pages use that same version.') }}
{{-- Webhook URL + verify token (copy) --}}
{{-- /facebook --}} {{-- ===== SMS ===== --}}
$section !== 'sms'])> {{-- SMS channel Master Hub --}}
{!! \App\Support\SvgIcon::inner('lucide', 'message-square-text') !!}
{{ __('channel') }}

{{ __('SMS Gateway Hub') }}

{{ __('Turn SMS ON platform-wide. Route two-way text messaging and broadcast blasts across 7 major gateways: Twilio, Vonage, Plivo, MessageBird, Sinch, Telnyx, and MSG91. Inbound texts thread into the unified Team Inbox, and sends are billed to workspace SMS plan quotas.') }}

{{-- Webhook URLs (copy) --}}
{{-- Section title --}}

{{ __('Supported SMS Gateways') }}

{{ __('Enable specific gateways and optionally configure platform-level credentials as defaults. Workspaces can also connect individual numbers at /devices.') }}

{{-- 1. Twilio --}}

Twilio SMS

Global messaging, high deliverability, automatic DLR callbacks
{{-- 2. Vonage --}}

Vonage (Nexmo)

Fast worldwide delivery with API Key & Secret verification
{{-- 3. Plivo --}}

Plivo

Enterprise SMS API with Auth ID & Auth Token verification
{{-- 4. MessageBird (Bird) --}}

MessageBird (Bird)

REST API SMS dispatch with live balance checks and Originator support
{{-- 5. Sinch --}}

Sinch

Service Plan & Batch SMS API with multi-region cluster support (US / EU)
{{-- 6. Telnyx --}}

Telnyx

Carrier-grade V2 REST API messaging with webhooks and detailed status tracking
{{-- 7. MSG91 --}}

MSG91 (India DLT)

TRAI DLT compliant SMS gateway for Indian traffic with 6-character Header support
{{-- /sms --}} {{-- ===== TIKTOK ===== --}}
$section !== 'tiktok'])> {{-- TikTok — a SEPARATE "TikTok for Developers" app (client_key/secret), plus Business Messaging + Shop. --}}
{{ __('channel') }}

{{ __('TikTok') }}

{{ __('A separate TikTok for Developers app. Create one at developers.tiktok.com, add the Login Kit, Display and Content Posting products, then paste its client key + secret below.') }} {{ __('Redirect URI to register:') }} {{ url('/tiktok/callback') }}

{{-- How to get the keys + why each is used --}}
{{ __('Where to get these keys') }}
  1. {{ __('Go to') }} developers.tiktok.com → {{ __('Manage apps → create an app.') }}
  2. {{ __('Add these products to the app:') }} {{ __('Login Kit, Display API, Content Posting API, Webhooks.') }}
  3. {{ __('Under the app\'s "Basic information", copy the') }} client key {{ __('and') }} client secret {{ __('into the fields above.') }}
  4. {{ __('Add the redirect URI') }} {{ url('/tiktok/callback') }} {{ __('(must be HTTPS — a local http://127.0.0.1 is rejected).') }}
  5. {{ __('Set the Webhook URL to') }} {{ url('/webhooks/tiktok') }}.
  6. {{ __('While the app is in review, request ONLY the Login Kit scopes') }} user.info.basic, user.info.profile, user.info.stats {{ __('(the default above). Add') }} video.list, video.upload {{ __('to "Login scopes" only AFTER the Display API and Content Posting API products are approved — requesting them earlier makes TikTok reject login with a "client_key" error.') }}
{{ __('Why each key:') }} {{ __('the client key identifies your app on the TikTok consent screen; the client secret signs the token exchange and verifies incoming webhook signatures. Both are stored encrypted.') }} {{ __('Login Kit docs') }} →
{{-- Business Messaging (DM inbox) — partner-gated + region-locked. --}}
{{ __('TikTok DM inbox (Business Messaging)') }}

{{ __('Separate "TikTok API for Business" app + Messaging Partner approval. NOT available in the US, EEA, Switzerland or UK. Comment-to-DM triggers are not offered by TikTok\'s API. Leave off until approved.') }}

{{ __('DM webhook callback:') }} {{ url('/webhooks/tiktok/business') }}
{{ __('Before enabling the DM inbox') }}
  1. {{ __('Create a separate app at') }} business-api.tiktok.com {{ __('(this is NOT the developers.tiktok.com app).') }}
  2. {{ __('Apply for the') }} {{ __('Messaging Partner') }} {{ __('specialty — TikTok may ask for business registration docs, a privacy-policy URL and your data-handling practices.') }}
  3. {{ __('The connected account must be a TikTok Business Account set to accept DMs from everyone, in a supported region.') }}
  4. {{ __('Register the DM webhook') }} {{ url('/webhooks/tiktok/business') }}.
{{ __('Region ban:') }} {{ __('the DM inbox will not work for accounts in the US, EEA, Switzerland or the UK — :brand blocks it automatically and shows the reason on the account.', ['brand' => brand_name()]) }}
{{-- TikTok Shop (App C) — buyer messaging + orders; lives with Shopify/Woo. --}}
{{ __('TikTok Shop') }}

{{ __('A third, separate app on the TikTok Shop Partner Center — powers buyer messaging + order context on the Integrations page. Needs the seller.customer_service scope approved.') }}

{{ __('Seller auth callback:') }} {{ url('/tiktok-shop/callback') }}
{{ __('Get these at') }} partner.tiktokshop.com {{ __('(US sellers:') }} partner.us.tiktokshop.com{{ __('). The region is fixed at registration and cannot change.') }}
{{-- /tiktok --}} {{-- ===== LINE ===== --}}
$section !== 'line'])>
{{ __('channel') }}

{{ __('LINE') }}

{{ __('LINE Messaging API — no central app needed. A workspace pastes its Official Account channel access token + secret and starts chatting in the inbox. Turn it on to give workspaces with the LINE plan feature the connect flow.') }} {{ __('Inbound webhook (per channel, auto-registered):') }} {{ url('/api/line/inbound/…') }}

{{-- ===== WECHAT ===== --}}
$section !== 'wechat'])>
{{ __('channel') }}

{{ __('WeChat') }}

{{ __('WeChat Official Account (certified Service Account) — no central app needed. A workspace pastes its AppID + AppSecret + server Token and starts chatting in the inbox. Turn it on to give workspaces with the WeChat plan feature the connect flow.') }} {{ __('Inbound webhook (per channel, pasted into the OA Server Config):') }} {{ url('/api/wechat/inbound/…') }}

{{-- ===== VIBER ===== --}}
$section !== 'viber'])>
{{ __('channel') }}

{{ __('Viber') }}

{{ __('Viber REST Bot API — no central app needed. A workspace pastes its Viber Public Account auth token and starts chatting in the inbox; we register the webhook automatically. Turn it on to give workspaces with the Viber plan feature the connect flow.') }} {{ __('Inbound webhook (per channel, auto-registered — needs a valid CA HTTPS domain):') }} {{ url('/api/viber/inbound/…') }}

{{-- ===== EMAIL ===== --}}
$section !== 'email'])>
{{ __('channel') }}

{{ __('Email') }}

{{ __('Native email channel — workspaces connect their own mailbox over IMAP + SMTP (Gmail, Outlook, Zoho, iCloud or any host). Inbound mail lands in the team inbox and replies send back over SMTP. Turn this on so workspaces with the Email plan feature get the connect flow on the Channels page. Add the OAuth app keys below for one-click Gmail / Outlook sign-in — optional; app-password connect works without them.') }}

{{-- OAuth app keys (optional) — one registration per install, like Google Calendar / social sign-in. With these set, the connect modal shows one-click "Sign in with Gmail / Outlook". Without them, workspaces connect with an app password over IMAP/SMTP. --}}
{{ __('One-click sign-in app keys (optional)') }}

{{ __('Register an app with Google and/or Microsoft, then paste the client id + secret here. Add the redirect URI shown under each as an authorised redirect in the provider console.') }}

{{-- Google --}}
G{{ __('Google (Gmail / Workspace)') }}
{{ __('Authorised redirect URI:') }} {{ url('/email/oauth/google/callback') }}
{{-- Microsoft --}}
⊞{{ __('Microsoft (Outlook / Microsoft 365)') }}
{{ __('Redirect URI:') }} {{ url('/email/oauth/microsoft/callback') }}
{{-- ===== TELEGRAM ===== --}}
$section !== 'telegram'])> {{-- Telegram — Bot API (no OAuth). Paste-a-token connect; optional api id/hash for the in-app bot maker. --}}
{{ __('channel') }}

{{ __('Telegram') }}

{{ __('No OAuth, no app review. A workspace pastes a bot token from @BotFather and starts chatting in the inbox. Turn it on to give workspaces with the Telegram plan feature the Channels connect flow.') }} {{ __('Inbound webhook (per bot, auto-registered):') }} {{ url('/api/telegram/inbound/…') }}

{{-- Optional: in-app bot maker (MTProto → @BotFather). --}}
{{ __('In-app bot maker (optional)') }}

{{ __('Lets a workspace log a Telegram account in and create bots with @BotFather from the dashboard, instead of pasting a token. Needs a Telegram API id + hash. Leave blank — the paste-a-token flow works without it.') }}

{{ __('Where to get these keys') }}
  1. {{ __('Sign in at') }} my.telegram.org → API development tools.
  2. {{ __('Create an app (any name) — Telegram shows an') }} api_id {{ __('and') }} api_hash. {{ __('Paste them above.') }}
  3. {{ __('The plain bot-token connect needs nothing here — only the in-app bot maker uses these.') }}
{{ __('Stored encrypted and passed to the Node bridge per request; they are never written to the browser.') }}
{{-- /telegram --}} {{-- ===== REGISTRATION OTP ===== --}}
$section !== 'whatsapp'])> {{-- Registration WhatsApp OTP verification — sends a code to the signup mobile on any engine. --}}
{{ __('auth · signup verification') }}

{{ __('Registration OTP verification') }}

When ON, new users must confirm a one-time code sent to their WhatsApp before the account is created. The code is sent from the device you pick below. On {{ __('WABA') }} it uses your approved {{ __('authentication') }} template; on {{ __('Unofficial') }} and {{ __('Twilio') }} it is sent as a text message. Default {{ __('OFF') }}.

{{ __('WABA auth template') }} {{-- One-click: builds the auth template in code + submits it to Meta against the selected WABA device. `formaction` posts THIS form (so the picked device rides along) to the create route. --}} {{ __('Creates the OTP message for the selected channel. WABA is submitted to Meta for approval; Unofficial and Twilio are approved instantly and ready to use.') }}
{{-- /otp --}} {{-- ===== META TEMPLATES ===== --}}
$section !== 'whatsapp'])> {{-- Phase 6 — Templates v2. Submits new templates to Meta on save, polls status, lints. --}}
{{ __('waba · template lifecycle') }}

{{ __('Meta template submission & sync') }}

When ON, every new template POSTs to /{WABA_ID}/message_templates on save. Approval status updates live via the {{ __('message_template_status_update') }} webhook plus an AJAX poll while the user has the detail page open. Default {{ __('OFF') }} — existing local-approval flow keeps working.

{{ __('Webhook poll') }}
30s
{{ __('client-side, while pending') }}
{{-- /templates --}} {{-- ===== WHATSAPP (engine selection + platform credentials) ===== --}}
$section !== 'whatsapp'])>

{{ __('Enabled messaging engines') }}

{{-- Engine cards — MULTI select. Click a card to enable/ disable that engine for the whole platform (any subset of the three). The small "default" radio on an enabled card sets the fallback engine for sends that don't pin a sender. The hidden checkbox (allowed_send_methods[]) + radio (default_engine) are what the form submits; clicking the card toggles them via JS. --}} @php $allowed = $settings['allowed_send_methods'] ?? ['baileys']; $allowed = is_array($allowed) ? $allowed : [$allowed]; $defaultProvider = $settings['default_send_method'] ?? ($allowed[0] ?? 'baileys'); // Three engines — Business API covers both the manual- // token paste workflow AND Embedded Signup (WABA login), // since they target the same Meta Cloud API + App creds. $engines = [ 'twilio' => [ 'key' => 'twilio', 'title' => 'Twilio', 'desc' => "Send via Twilio's WhatsApp sandbox or production sender.", ], 'wa-api' => [ 'key' => 'baileys', 'title' => 'Unofficial API', 'desc' => 'Self-hosted Node bridge. Lower cost, unofficial.', ], 'business-api' => [ 'key' => 'waba', 'title' => 'Business API (WABA)', 'desc' => 'Meta Cloud API — manual token or Embedded Signup.', ], ]; // Unofficial API (baileys) ships as a removable add-on and is // hidden platform-wide when it is not installed — drop its engine // card so an admin can't enable an engine the product doesn't // ship. Single master gate (matches the data layer + /devices). if (! \App\Services\WorkspaceEngine::unofficialEnabled()) { unset($engines['wa-api']); } @endphp
@foreach ($engines as $slug => $eng) @php $on = in_array($eng['key'], $allowed, true); $isDefault = $eng['key'] === $defaultProvider; @endphp
{{-- Visible enable checkbox — tick the engines you want (any subset). --}} {{ $on ? __('enabled') : __('off') }} {{-- Default-engine picker — only selectable when this engine is ticked. --}}
{{ $eng['title'] }}
{{ $eng['desc'] }}
{{-- Active marker — shown only on the default engine (the one that handles sends with no specific sender). Other cards show nothing. --}}
@if ($isDefault) {{ __('Active') }} @else   @endif
@endforeach

{{ __('Tick the engines you want available platform-wide. The "default" radio marks which engine handles sends that do not pick a specific number — every other send uses whichever number the operator chooses.') }}

{{ __('Switching engines mid-traffic drops in-flight queues. Pause campaigns first, then change.') }}
@if (\App\Services\WorkspaceEngine::unofficialEnabled()) @endif
{{-- /whatsapp engines --}} {{-- AI assistance section removed — AI keys aren't entered here. Platform admins manage provider keys at /admin/api-keys, and workspace owners enter their own BYOK keys at /settings (per-workspace). --}} {{-- ===== SENDER PACING ===== --}}
$section !== 'whatsapp'])> {{-- Sender pacing — the throttle Node applies (msg_gap / batches_gap / bw_msg_gap / enable_batches). --}}
{{ __('pacing') }}

{{ __('Sender pacing & batching') }}

{{-- Quick "Update timing" — saves ONLY the four pacing fields above (and pushes them to the Node bridge) without submitting the whole providers form. --}}
{{-- /pacing --}} {{-- ===== CAMPAIGN AUTO-END ===== --}}
$section !== 'whatsapp'])> {{-- Campaign auto-end (expiry). Saves with the main Save button. --}}
{{ __('campaigns') }}

{{ __('Campaign auto-end') }}

{{ __('Stops a one-off campaign from sending for days (e.g. an event blast still going a week later). A campaign that uses a daily cap or a send-window is deliberately multi-day and is never auto-ended. Operators can also set an exact end date per campaign.') }}

{{-- /campaign --}}
@endif {{-- end detail ($section) --}}