import{r as v,j as e,H as _,L as m,a as x}from"./app-BeNY_zSm.js";import{A as T}from"./app-layout-DgG7GJrd.js";import{H as S}from"./heading-CT-LucMJ.js";import{B as n}from"./button-Dge8PO59.js";import{C as o,b as l,c as d,a as i,d as I}from"./card-DG7I-_3R.js";import{P as g,A as b,B as h,a as R}from"./index-Bdohy6kp.js";import{P as A}from"./page-help-DTCPMpQ7.js";import{d as M}from"./index-6bh5m_Va.js";import{C as p}from"./circle-check-Cbr55h3A.js";import{C as P}from"./circle-x-Cqpugu36.js";import{T as E}from"./test-tube-CiLMkrwq.js";import{S as H}from"./square-pen-JC_-Hua4.js";import{T as D}from"./trash-2-CkyRKENG.js";import{f as L}from"./format-Blk6h8U7.js";/* empty css            */import"./checkbox-CP6n_Jsi.js";import"./check-ApYQKYPd.js";import"./createLucideIcon-VdTyGa1S.js";import"./minus-DZw6Ijz4.js";import"./app-logo-icon-vDeU-Cqe.js";import"./house-DocrF1YH.js";import"./phone-BwMlHUyB.js";import"./user-cog-CmNZBMeK.js";import"./alert-CxSnbwwr.js";import"./circle-alert-DR8wP1n1.js";import"./input-C0y5Yptz.js";import"./label-GwfI79i1.js";import"./loader-circle-B3vU0DzH.js";import"./circle-help-BK6Ftcl-.js";import"./external-link-B9pahLkG.js";import"./en-US-e8bDGnU5.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"d90f819d28d132ee9ad7641cbed0d6343dd98ccf"}}catch{}})();try{(function(){var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new s.Error().stack;a&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[a]="a52296d7-df22-49b7-a11e-2f995c0ff60b",s._sentryDebugIdIdentifier="sentry-dbid-a52296d7-df22-49b7-a11e-2f995c0ff60b")})()}catch{}function ue({integrations:s,stats:a}){const[u,f]=v.useState(null),j=t=>{confirm("Are you sure you want to delete this integration?")&&x.delete(`/api/v1/crm-integrations/${t}`,{preserveScroll:!0,onSuccess:()=>{x.reload({only:["integrations","stats"]})}})},y=async t=>{f(t);try{const c=await(await fetch(`/api/v1/crm-integrations/${t}/test`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":document.querySelector('meta[name="csrf-token"]')?.getAttribute("content")||""}})).json();c.success?alert(`✅ ${c.data.message}

Status: ${c.data.status}`):alert(`❌ ${c.data.message}`),x.reload({only:["integrations"]})}catch(r){alert("Failed to test webhook: "+r.message)}finally{f(null)}},w=t=>({call_completed:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",lead_qualified:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",contact_added:"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-400",contact_updated:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400",campaign_started:"bg-indigo-100 text-indigo-800 dark:bg-indigo-900/30 dark:text-indigo-400",dtmf_response:"bg-pink-100 text-pink-800 dark:bg-pink-900/30 dark:text-pink-400"})[t]||"bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-400",k=t=>({call_completed:"Call Completed",lead_qualified:"Lead Qualified",contact_added:"Contact Added",contact_updated:"Contact Updated",campaign_started:"Campaign Started",dtmf_response:"DTMF Response"})[t]||t,C=[{title:"Dashboard",href:M().url},{title:"CRM Integrations",href:"/integrations"}],N=[{title:"What are CRM Integrations?",content:"CRM Integrations allow you to automatically send call data, leads, and contact updates to your CRM or marketing tools in real-time using webhooks. Teleman pushes data TO your CRM via HTTP POST requests - no code changes needed in Teleman for each CRM."},{title:"How to Integrate Any CRM",content:`Step 1: Create a webhook endpoint in your CRM that accepts POST requests with JSON data.
Step 2: Generate API credentials (Bearer token, API key, or HMAC secret).
Step 3: Click "Add Integration" in Teleman, fill in the webhook URL and credentials.
Step 4: Select which events to track and click "Test Integration" to verify.
Step 5: Activate and monitor webhook logs for delivery status.`},{title:"Supported Events",content:`• Call Completed: Full call data with transcripts, duration, sentiment analysis
• Lead Qualified: Hot leads detected by AI with sentiment scores
• Contact Added: New contacts created or imported
• Contact Updated: Changes to contact information
• Campaign Started: Campaign launch notifications
• DTMF Response: Phone keypress tracking for IVR`},{title:"Authentication Methods",content:`• Bearer Token (OAuth 2.0): Standard for most modern CRMs like HubSpot, Salesforce
• API Key: Custom header authentication (e.g., X-API-Key)
• HMAC Signature: Maximum security with cryptographic payload verification
• None: For testing only (not recommended for production)`},{title:"Webhook Payload Example",content:`When a call completes, your CRM receives:
{
  "event": "call_completed",
  "call_id": 123,
  "contact_name": "John Doe",
  "phone_number": "+15551234567",
  "duration": 120,
  "transcript": "Full conversation...",
  "sentiment_score": 0.85,
  "sentiment": "positive",
  "recording_url": "https://..."
}`},{title:"Testing & Monitoring",content:"Use the Test button to send a sample webhook and verify your integration. Check Webhook Logs for delivery history, response status codes, and error messages. Failed webhooks can be retried with a single click. Monitor success rate and recent activity in the stats dashboard."},{title:"Popular CRM Examples",content:`• ERPNext: Create @frappe.whitelist() endpoint in api.py
• Salesforce: Create Apex REST Resource
• HubSpot: Use workflow webhook trigger or Private App
• Zoho: Create Deluge script or webhook handler
• Pipedrive: Use API endpoint with API Key
• Custom CRM: Any REST API accepting POST requests`},{title:"Troubleshooting",content:`If webhooks aren't sending: Ensure integration is Active and events are selected. Check Laravel queue is running.

If getting 401 Unauthorized: Verify API credentials are correct. Test token with curl first.

If getting 500 errors: Check your CRM logs for endpoint errors. Ensure data format matches expected structure.

If timeouts occur: CRM endpoint must respond within 30 seconds. Use background jobs for long operations.`}];return e.jsxs(T,{breadcrumbs:C,children:[e.jsx(_,{title:"CRM Integrations"}),e.jsxs("div",{className:"mx-auto max-w-7xl space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(S,{title:"CRM Integrations",description:"Connect Teleman to your CRM and marketing tools"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{title:"CRM Integrations Help",sections:N,documentationUrl:"/docs/documentation.html#crm-integrations"}),e.jsx(m,{href:"/integrations/create",children:e.jsxs(n,{children:[e.jsx(g,{className:"mr-2 h-4 w-4"}),"Add Integration"]})})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[e.jsxs(o,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Total Integrations"}),e.jsx(b,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(i,{children:[e.jsx("div",{className:"text-2xl font-bold",children:a.total_integrations}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.active_integrations," active"]})]})]}),e.jsxs(o,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Webhooks Sent"}),e.jsx(p,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(i,{children:[e.jsx("div",{className:"text-2xl font-bold",children:a.total_webhooks_sent}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.webhooks_last_24h," in last 24h"]})]})]}),e.jsxs(o,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Success Rate"}),e.jsx(p,{className:"h-4 w-4 text-green-600 dark:text-green-400"})]}),e.jsxs(i,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[a.success_rate,"%"]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.successful_webhooks," successful"]})]})]}),e.jsxs(o,{children:[e.jsxs(l,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Failed Webhooks"}),e.jsx(P,{className:"h-4 w-4 text-red-600 dark:text-red-400"})]}),e.jsxs(i,{children:[e.jsx("div",{className:"text-2xl font-bold",children:a.failed_webhooks}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Need attention"})]})]})]}),s.length===0?e.jsx(o,{children:e.jsxs(i,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(b,{className:"mb-4 h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mb-2 text-lg font-semibold",children:"No CRM integrations yet"}),e.jsx("p",{className:"mb-6 text-center text-muted-foreground",children:"Connect your CRM to automatically sync calls, leads, and contacts"}),e.jsx(m,{href:"/integrations/create",children:e.jsxs(n,{children:[e.jsx(g,{className:"mr-2 h-4 w-4"}),"Create Your First Integration"]})})]})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:s.map(t=>e.jsxs(o,{className:t.is_active?"":"opacity-60",children:[e.jsx(l,{children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs(d,{className:"flex items-center gap-2",children:[t.name,t.is_active?e.jsxs(h,{variant:"default",className:"bg-green-600",children:[e.jsx(p,{className:"mr-1 h-3 w-3"}),"Active"]}):e.jsx(h,{variant:"secondary",children:"Inactive"})]}),e.jsx(I,{className:"mt-2 break-all",children:t.webhook_url})]})})}),e.jsxs(i,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Subscribed Events"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.events.map(r=>e.jsx(h,{variant:"secondary",className:w(r),children:k(r)},r))})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(R,{className:"h-4 w-4"}),e.jsxs("span",{children:[t.total_triggers," triggers"]})]}),t.last_triggered_at&&e.jsxs("div",{children:["Last: ",L(new Date(t.last_triggered_at),"MMM d, HH:mm")]})]}),t.last_error&&e.jsx("div",{className:"rounded-md bg-red-50 p-3 dark:bg-red-950/20",children:e.jsxs("p",{className:"text-sm text-red-800 dark:text-red-400",children:[e.jsx("strong",{children:"Last Error:"})," ",t.last_error]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(n,{variant:"outline",size:"sm",onClick:()=>y(t.id),disabled:u===t.id,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),u===t.id?"Testing...":"Test"]}),e.jsx(m,{href:`/integrations/${t.id}/logs`,children:e.jsx(n,{variant:"outline",size:"sm",children:"View Logs"})}),e.jsx(m,{href:`/integrations/${t.id}/edit`,children:e.jsxs(n,{variant:"outline",size:"sm",children:[e.jsx(H,{className:"mr-2 h-4 w-4"}),"Edit"]})}),e.jsxs(n,{variant:"destructive",size:"sm",onClick:()=>j(t.id),children:[e.jsx(D,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})]},t.id))})]})]})}export{ue as default};
//# sourceMappingURL=index-BfCI73yU.js.map
