import { defineFrontComponent } from 'twenty-sdk/define'; import React, { useEffect, useState } from 'react'; type SourceData = { id: string; name: string; slug: string; status: string; targetObject: string; webhookSecret: string | null; totalIngested: number; lastIngestedAt: string | null; createOpportunity: boolean; opportunityNameTemplate: string; }; const copyIcon = ``; const SourcePanel: React.FC<{ recordId?: string }> = ({ recordId }) => { const [source, setSource] = useState(null); const [copied, setCopied] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { if (!recordId) { setLoading(false); return; } const apiUrl = (window as any).__TWENTY_API_URL__ ?? ''; const token = (window as any).__TWENTY_API_TOKEN__ ?? ''; fetch(`${apiUrl}/rest/intakeSources/${recordId}`, { headers: { Authorization: `Bearer ${token}` }, }) .then(r => r.json()) .then(d => setSource(d.data?.intakeSource ?? null)) .finally(() => setLoading(false)); }, [recordId]); const copy = (text: string, key: string) => { navigator.clipboard.writeText(text).then(() => { setCopied(key); setTimeout(() => setCopied(null), 2000); }); }; const webhookUrl = source ? `${(window as any).__TWENTY_API_URL__ ?? 'https://your-crm.com'}/s/intake/${source.slug}` : ''; if (loading) return
Loading...
; if (!source) return
Source not found.
; const Code: React.FC<{ value: string; copyKey: string }> = ({ value, copyKey }) => (
{value}
); return (
{source.status} → {source.targetObject} {source.totalIngested} ingested {source.lastIngestedAt && ` · last ${new Date(source.lastIngestedAt).toLocaleDateString()}`}
Webhook URL
POST this URL from your platform to ingest leads.
{source.webhookSecret && (
Signing Secret
HMAC-SHA256 sign requests with this secret. Header: X-Webhook-Signature: sha256=<digest>
)}
Dry-run URL
Test any payload without writing to the CRM.
Quick send
{`curl -X POST "${webhookUrl}" \\
  -H "Content-Type: application/json" \\
  -d '{"first_name":"Jane","email":"jane@co.com","company":"Acme"}'`}
); }; export default defineFrontComponent({ universalIdentifier: 'c9d2e8f3-1b4a-4c7d-9e5f-6a7b8c0d1e2f', name: 'intake-source-panel', description: 'Shows the webhook URL, signing secret, and quick-send snippet for an Intake Source.', component: SourcePanel, });