Lead generation¶
The Get Swapps section (/get-swapps/) is the Website's lead-generation
system: a set of multi-step surveys plus a manual contact form. Submissions are
sent to the Platform Worker (swapps-worker), which handles CRM/email
integrations; AI-assisted features call the AI Worker (swapps-ai).
/api/seo/analyze| Plat Survey -.->|POST /api/ai/recommend-plan| AI[AI · swapps-ai] Plat --> CRM[Pipedrive / Mailgun]
Survey framework¶
Each survey is built on a generic, reusable engine
(pages/get-swapps/partials/survey/GenericSurvey.tsx) and described by four files
per survey type:
| File | Role |
|---|---|
{Name}Constants.ts |
Step definitions, options, choices |
{Name}Types.ts |
TypeScript interfaces for the form data |
{Name}Survey.tsx |
The survey component (renders GenericSurvey) |
{name}SurveyConfig.ts |
API endpoints and the submission transform |
Available surveys include Diagnostic, SEO Diagnostic, Dedicated Team, Technology Strategy, Process Automation, System Improvement, Scaling, and Strategic Advice.
Survey config example¶
diagnosticSurveyConfig.ts declares the steps (question → URL → register →
results), the analysis endpoint, the submit endpoint, and how form fields are
transformed into the lead payload:
export const diagnosticSurveyConfig = {
surveyType: "diagnostic",
serviceType: "development-support",
steps: [...questionSteps, urlStep, registerStep, resultsStep],
apiAnalyzeEndpoint: `${__API_URL__}/api/diagnostic/analyze`,
apiSubmitEndpoint: `${__API_URL__}/api/leads`,
transformFormDataForSubmission: (formData, result, serviceTitle, recaptchaToken, language) => ({
personal: { name: formData.fullName, email_address: formData.email, /* … */ },
diagnostic: { service: "development-support", website_url: formData.websiteUrl, /* … */ },
recaptchaToken,
language,
}),
};
Endpoints used¶
These all live on the Platform Worker (reached via __API_URL__ /
API_WORKER), except AI:
| Endpoint | Method | Purpose |
|---|---|---|
/api/leads |
POST | Submit survey / lead form data |
/api/diagnostic/analyze |
POST | Website diagnostic analysis |
/api/seo/analyze |
POST | SEO diagnostic analysis |
/api/support/send |
POST | Manual contact form |
/api/ai/recommend-plan |
POST | AI plan recommendation (AI Worker, src/api/ai.ts) |
Note
Survey submissions happen client-side (after hydration, in response to the
user), so they go out as normal HTTPS requests to the Platform Worker's public
URL (__API_URL__) rather than over the API_WORKER Service Binding — the
binding only exists inside the Worker during SSR. See
Service bindings.
Spam protection¶
All form submissions require a Google reCAPTCHA v3 token (ReCaptcha.tsx,
site key baked in as __RECAPTCHA_SITE_KEY__). The token is passed through the
survey's transformFormDataForSubmission into the payload and validated by the
backend.
Manual contact form¶
ManualContactForm.tsx provides direct contact and integrates Calendly for
scheduling. It submits to /api/support/send.
AI-assisted recommendations¶
The AI Worker (swapps-ai) powers plan recommendations and refinement. The client
in src/api/ai.ts calls POST /api/ai/recommend-plan with a free-text message,
optional locale, source, pageUrl, and structured fields. The route is
mounted at swapps.com/api/ai/* and routed by Cloudflare to the AI Worker; from
local dev an absolute URL works too.