PageSourceSearch

https://aidealer360.com/assets/MessengerAutoReply-B00i4rlm.js

js aidealer360.com collected 2026-09-24 12:37:23 UTC 15,804 bytes, 1 lines download raw bytes

1import{j as e}from"./ui-vendor-B12AOeKi.js";import{r as m}from"./react-vendor-DZt7wVAJ.js";import{a as z,P as C,J as G,B as E,q as w,af as I,L as d,I as S,aL as H,g as J,s as M,i as h}from"./index-CUOC2qQu.js";import{T as j}from"./textarea-BsyLd3-L.js";import{S as q}from"./switch-Doi0_Deq.js";import{S as K}from"./separator-BMNKkNil.js";import{S as Q}from"./sparkles-CevhEv4S.js";import{E as U}from"./external-link-C8QIAkqQ.js";import"./charts-vendor-B6q1L48j.js";import"./supabase-vendor-dOy44Gxq.js";import"./animation-vendor-BAVy02gd.js";const V={enabled:!0,auto_reply_master_enabled:!1,persona_tone:"friendly",pricing_stance:"negotiable",max_ai_msgs_per_convo:6,max_conversations_to_check:30,hourly_send_cap:20,daily_send_cap:100,quiet_hours_start:21,quiet_hours_end:8,followup_enabled:!1,followup_interval_hours:6,followup_max_attempts:3,handoff_triggers:["price negotiation","trade-in","financing","complaint","legal"]},X="cjpdnappamdebjpbkbnkmmkonbbdighl";function ce(){const{selectedDealership:c}=z(),[t,p]=m.useState(null),[g,f]=m.useState(!1),[b,y]=m.useState(!1),[k,A]=m.useState([]),[R,D]=m.useState(!0);async function N(){if(!(c!=null&&c.id))return;D(!0);const{data:s}=await M.from("m360_messenger_settings").select("*").eq("dealership_id",c.id).maybeSingle();p({...V,dealership_id:c.id,...s||{}});const{data:a}=await M.from("m360_messenger_messages").select("id, body, status, confidence, intent, created_at, automated, thread_id, m360_messenger_threads!inner(buyer_name, dealership_id)").eq("automated",!0).eq("m360_messenger_threads.dealership_id",c.id).order("created_at",{ascending:!1}).limit(20);A(a||[]),D(!1)}m.useEffect(()=>{N()},[c==null?void 0:c.id]),m.useEffect(()=>{if(!t)return;const s=!!t.auto_reply_master_enabled;try{localStorage.setItem("m360_autoreply_enabled",s?"1":"0")}catch{}window.dispatchEvent(new CustomEvent("m360:autoreply-master-changed",{detail:{enabled:s}}))},[t==null?void 0:t.auto_reply_master_enabled]);async function L(){if(!t)return;f(!0);const s={...t},{error:a}=await M.from("m360_messenger_settings").upsert(s,{onConflict:"dealership_id"});if(f(!1),a)return h.error("Save failed: "+a.message);h.success("Auto-reply settings saved"),N()}function i(s,a){p(r=>r&&{...r,[s]:a})}function $(s){p(a=>a&&{...a,enabled:s,auto_reply_master_enabled:s})}const P=m.useMemo(()=>t?!t.persona_name&&!t.default_intro_template&&!t.signature:!0,[t]);function F(s,a){return s?s==="no-messenger-tab"?"No open Facebook Messages tab was found. Open Facebook Messages, then run the test again.":s==="extension-not-reachable"?"Marketplace360 v1.0.96+ is not reachable from this page. Install the latest package, reload the extension, then refresh this page.":s==="origin-not-allowed"?"This site is not allowed to talk to the Marketplace360 extension. Use aidealer360.com after publishing the latest app.":s==="sidebar-not-found"?`Facebook Messages is open, but the conversation list was not found. Thread links visible: ${(a==null?void 0:a.threadLinksFound)??0}; Marketplace rows visible: ${(a==null?void 0:a.marketplaceRowsFound)??0}. If you are on Marketplace Inbox, keep the buyer queue open and install Marketplace360 v1.0.96+.`:s==="rows-not-found"?`Facebook Messages was found, but no conversation rows were detected. Thread links visible: ${(a==null?void 0:a.threadLinksFound)??0}; Marketplace rows visible: ${(a==null?void 0:a.marketplaceRowsFound)??0}. If the Marketplace queue is visible, install Marketplace360 v1.0.96+ and refresh Facebook.`:s==="not-messages-route"?"The Facebook tab is not on a Messages inbox route. Open facebook.com/messages or Marketplace inbox, then retry.":s==="composer-missing"?"The scan found conversations, but Facebook's message composer was not available after opening them.":s.includes("Receiving end does not exist")?"Facebook Messages is open, but the extension was not attached yet. Refresh the Facebook Messages tab, then run the test again.":s.includes("Cannot access")||s.includes("scripting")?"The extension could not attach to Facebook Messages. Reload the extension package, refresh Facebook Messages, then try again.":`Test scan failed: ${s}`:"Test scan failed before it reached Facebook Messages."}function T(s){var u,o;const a=(s==null?void 0:s.delivered)||1,r=(s==null?void 0:s.rowsFound)??((o=(u=s==null?void 0:s.results)==null?void 0:u[0])==null?void 0:o.rowsFound);return typeof r=="number"&&r>0?`Test scan started in ${a} Facebook Messages tab${a===1?"":"s"}; ${r} conversation${r===1?"":"s"} detected. Watch the Facebook overlay for send progress.`:`Test scan delivered to ${a} Facebook Messages tab${a===1?"":"s"}. Watch the Facebook overlay for progress.`}function W(s){return new Promise(a=>{var u;const r=(u=window.chrome)==null?void 0:u.runtime;if(!(r!=null&&r.sendMessage)){a({ok:!1,error:"chrome-runtime-unavailable"});return}try{r.sendMessage(X,{type:"m360:testScanNow",template:s},o=>{var n;const _=(n=r.lastError)==null?void 0:n.message;a(_?{ok:!1,error:_}:o||{ok:!1,error:"extension-not-reachable"})})}catch(o){a({ok:!1,error:(o==null?void 0:o.message)||String(o||"direct-send-failed")})}})}function O(){if(!t||b)return;y(!0);const s=t.default_followup_template||"",a=`m360-test-${Date.now()}-${Math.random().toString(36).slice(2)}`;let r=!1,u;const o=()=>{r=!0,u&&window.clearTimeout(u),window.removeEventListener("message",_),y(!1)},_=n=>{var v,B;const l=n.data;!l||l.source!=="m360-extension"||l.type!=="m360:testScanResult"||l.requestId!==a||(o(),l.ok?h.success(T(l)):h.error(F(l.error,((B=(v=l.failures)==null?void 0:v[0])==null?void 0:B.details)||l)))};window.addEventListener("message",_),u=window.setTimeout(()=>{r||(o(),h.error(F("extension-not-reachable")))},1e4);try{W(s).then(n=>{var l,v;r||(n==null?void 0:n.error)==="chrome-runtime-unavailable"||(o(),n!=null&&n.ok?h.success(T(n)):h.error(F(n==null?void 0:n.error,((v=(l=n==null?void 0:n.failures)==null?void 0:l[0])==null?void 0:v.details)||n)))}),window.postMessage({source:"aidealer360",type:"m360:testScanNow",requestId:a,template:s},"*")}catch(n){o(),h.error("Could not trigger test scan: "+((n==null?void 0:n.message)||String(n)))}}return R||!t?e.jsxs("div",{className:"p-6 text-[#9FB3C8] flex items-center gap-2",children:[e.jsx(C,{className:"w-4 h-4 animate-spin"})," Loading…"]}):e.jsxs("div",{className:"p-4 md:p-6 space-y-6 max-w-5xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-semibold text-[#E6EDF3] flex items-center gap-2",children:[e.jsx(G,{className:"w-6 h-6"})," Marketplace Auto-Reply"]}),e.jsx("p",{className:"text-sm text-[#9FB3C8] mt-1",children:"The Chrome extension scans your Facebook Marketplace inbox and replies to new buyer messages using the knowledge base below. Keep the Messages tab open to run."})]}),e.jsxs(E,{onClick:L,disabled:g,className:"shrink-0",children:[g?e.jsx(C,{className:"w-4 h-4 animate-spin mr-2"}):null," Save changes"]})]}),e.jsxs(w,{className:"p-5 bg-white/[0.03] border-white/10",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(I,{className:"w-5 h-5 mt-1 text-[#2F80ED]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[#E6EDF3] font-medium",children:"Auto-Reply master switch"}),e.jsx("div",{className:"text-xs text-[#9FB3C8] mt-1",children:"Off = extension only captures messages. O
1n = extension sends AI replies within your caps. Turning off pauses replies within one scan cycle (~30s), even for tabs already open."})]})]}),e.jsx(q,{checked:t.auto_reply_master_enabled,onCheckedChange:$})]}),t.auto_reply_master_enabled&&P&&e.jsx("div",{className:"mt-4 p-3 rounded-md bg-yellow-500/10 text-yellow-200 text-xs",children:"Add a persona name, intro template, or signature below — the AI needs a voice before it can send."}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-white/10 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-xs text-[#9FB3C8]",children:[e.jsx("span",{className:"text-[#E6EDF3] font-medium",children:"Test scan"})," — sends your follow-up template to every visible conversation in your open Facebook Messages tab. Bypasses unread filters; skips the AI edge function; does not count against caps."]}),e.jsxs(E,{variant:"outline",size:"sm",disabled:!t.auto_reply_master_enabled||b,title:t.auto_reply_master_enabled?"Run test scan on open Messenger tab":"Turn the master switch on first","aria-label":"Run a test scan that sends the follow-up template to every visible conversation",onClick:O,children:[b?e.jsx(C,{className:"w-4 h-4 animate-spin mr-2"}):null," Run test scan"]})]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs(w,{className:"p-5 bg-white/[0.03] border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[#E6EDF3] font-medium",children:[e.jsx(Q,{className:"w-4 h-4 text-[#2F80ED]"})," Dealership voice"]}),e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:"Persona name (how the AI signs in)"}),e.jsx(S,{value:t.persona_name||"",onChange:s=>i("persona_name",s.target.value),placeholder:"e.g. Northampton VW Sales"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:"Tone"}),e.jsxs("select",{className:"w-full h-9 rounded-md bg-black/25 border border-white/10 px-2 text-[#E6EDF3] text-sm",value:t.persona_tone,onChange:s=>i("persona_tone",s.target.value),children:[e.jsx("option",{value:"friendly",children:"Friendly"}),e.jsx("option",{value:"professional",children:"Professional"}),e.jsx("option",{value:"casual",children:"Casual"}),e.jsx("option",{value:"enthusiastic",children:"Enthusiastic"})]})]}),e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:"Pricing stance"}),e.jsxs("select",{className:"w-full h-9 rounded-md bg-black/25 border border-white/10 px-2 text-[#E6EDF3] text-sm",value:t.pricing_stance,onChange:s=>i("pricing_stance",s.target.value),children:[e.jsx("option",{value:"firm",children:"Firm price"}),e.jsx("option",{value:"negotiable",children:"Negotiable"}),e.jsx("option",{value:"range",children:"Give a range"})]})]})]}),e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:"Intro template (used when the AI opens a conversation)"}),e.jsx(j,{rows:2,value:t.default_intro_template||"",onChange:s=>i("default_intro_template",s.target.value),placeholder:"Hey! Yes, it's still available — want me to hold it for you?"})]}),e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:"Follow-up template"}),e.jsx(j,{rows:2,value:t.default_followup_template||"",onChange:s=>i("default_followup_template",s.target.value),placeholder:"Just checking in — is this still on your radar?"})]}),e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:"Signature (appended to every AI reply)"}),e.jsx(j,{rows:2,value:t.signature||"",onChange:s=>i("signature",s.target.value),placeholder:"- Sales @ Northampton VW"})]})]}),e.jsxs(w,{className:"p-5 bg-white/[0.03] border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[#E6EDF3] font-medium",children:[e.jsx(I,{className:"w-4 h-4 text-[#2F80ED]"})," Guardrails"]}),e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:"Financing blurb"}),e.jsx(j,{rows:2,value:t.financing_blurb||"",onChange:s=>i("financing_blurb",s.target.value),placeholder:"We work with 15+ lenders — I can connect you with our finance manager for a real quote."})]}),e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:"Disclaimer (always ends reply, e.g. price disclaimer)"}),e.jsx(j,{rows:2,value:t.disclaimer||"",onChange:s=>i("disclaimer",s.target.value),placeholder:"Price + tax, title, and $499 doc fee. Subject to prior sale."})]}),e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:"Test-drive scheduler link"}),e.jsx(S,{value:t.test_drive_link||"",onChange:s=>i("test_drive_link",s.target.value),placeholder:"https://calendly.com/..."})]}),e.jsx(K,{className:"bg-white/10"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(x,{label:"Max AI replies / convo",value:t.max_ai_msgs_per_convo,onChange:s=>i("max_ai_msgs_per_convo",s),min:1,max:20}),e.jsx(x,{label:"Convos checked / scan",value:t.max_conversations_to_check,onChange:s=>i("max_conversations_to_check",s),min:5,max:100}),e.jsx(x,{label:"Hourly send cap",value:t.hourly_send_cap,onChange:s=>i("hourly_send_cap",s),min:1,max:200}),e.jsx(x,{label:"Daily send cap",value:t.daily_send_cap,onChange:s=>i("daily_send_cap",s),min:1,max:1e3}),e.jsx(x,{label:"Quiet hours start (24h)",value:t.quiet_hours_start,onCh
1ange:s=>i("quiet_hours_start",s),min:0,max:23}),e.jsx(x,{label:"Quiet hours end (24h)",value:t.quiet_hours_end,onChange:s=>i("quiet_hours_end",s),min:0,max:23})]})]})]}),e.jsxs(w,{className:"p-5 bg-white/[0.03] border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[#E6EDF3] font-medium",children:[e.jsx(H,{className:"w-4 h-4 text-[#2F80ED]"})," Follow-ups"]}),e.jsx(q,{checked:t.followup_enabled,onCheckedChange:s=>i("followup_enabled",s)})]}),e.jsx("p",{className:"text-xs text-[#9FB3C8]",children:"Re-engage buyers who went cold. Follow-ups respect quiet hours and the per-conversation reply cap."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 max-w-md",children:[e.jsx(x,{label:"Wait before follow-up (hours)",value:t.followup_interval_hours,onChange:s=>i("followup_interval_hours",s),min:1,max:72,disabled:!t.followup_enabled}),e.jsx(x,{label:"Max follow-up attempts",value:t.followup_max_attempts,onChange:s=>i("followup_max_attempts",s),min:1,max:10,disabled:!t.followup_enabled})]})]}),e.jsxs(w,{className:"p-5 bg-white/[0.03] border-white/10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-[#E6EDF3] font-medium",children:"Recent automated replies"}),e.jsx(E,{variant:"outline",size:"sm",onClick:N,children:"Refresh"})]}),k.length===0?e.jsx("div",{className:"text-sm text-[#9FB3C8] py-6 text-center",children:"No automated replies yet. Turn on the master switch and keep your Facebook Messages tab open."}):e.jsx("div",{className:"space-y-2",children:k.map(s=>{var a;return e.jsxs("div",{className:"p-3 rounded-md bg-black/20 border border-white/5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-[#9FB3C8] mb-1",children:[e.jsx("span",{children:((a=s.m360_messenger_threads)==null?void 0:a.buyer_name)||"Buyer"}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.intent&&e.jsx(J,{variant:"secondary",className:"text-[10px]",children:s.intent}),typeof s.confidence=="number"&&e.jsxs("span",{className:"text-[10px]",children:["conf ",(s.confidence*100).toFixed(0),"%"]}),e.jsx("span",{children:new Date(s.created_at).toLocaleString()})]})]}),e.jsx("div",{className:"text-sm text-[#E6EDF3] whitespace-pre-wrap",children:s.body})]},s.id)})})]}),e.jsxs("div",{className:"text-xs text-[#7C8FA6] flex items-center gap-1",children:[e.jsx(U,{className:"w-3 h-3"}),"The Chrome extension must be installed and signed in.",e.jsx("a",{href:"/marketplace360/extension",className:"underline hover:text-[#2F80ED] ml-1",children:"Install / update the extension →"})]})]})}function x({label:c,value:t,onChange:p,min:g,max:f,disabled:b}){return e.jsxs("div",{children:[e.jsx(d,{className:"text-[#B8C7D9] text-xs",children:c}),e.jsx(S,{type:"number",value:t,min:g,max:f,disabled:b,onChange:y=>{const k=Math.max(g,Math.min(f,Number(y.target.value)||0));p(k)}})]})}export{ce as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.