AI website form setup
If a site generated with Lovable, Bolt, ChatGPT, or another AI tool has a form but no submission handler, connect it to a SmartFormify endpoint. Keep the design, save responses, and configure email notifications without adding a separate form server.
If the form already has a working backend, review its setup before replacing it.
Paste this into the tool that edits your website. Replace the submit URL first, then review the resulting changes.
Prompt for your AI website builder
Connect the existing contact form to this public SmartFormify submit URL:
https://api.smartformify.com/fe/YOUR_ENDPOINT_KEY
Keep the current design and accessible field labels. Use POST. For plain HTML,
set the form action and give each submitted field a name attribute. For a React
or JavaScript submit handler, send JSON as { "data": { "name": "...",
"email": "...", "message": "..." } } with Content-Type: application/json.
Use the real input values, not these placeholders.
For JSON submissions, disable the submit button while sending. Read the HTTP
status and the response JSON. Show success only if response.ok and result.success
are true. If result.data.redirect_url is present, navigate to it. Otherwise show
a plain-text success confirmation and reset the form. On failure, keep the
entered values and show an accessible error with a retry option. Catch network
errors and re-enable the button in a finally block. Do not expose private API
tokens. This submit URL is public; I will configure allowed domains in SmartFormify.
Do not create a second backend or change unrelated parts of the website.A plain HTML form needs an action, a POST method, and named fields. SmartFormify handles the response page or configured redirect.
Plain HTML form
<form id="contact-form" action="https://api.smartformify.com/fe/YOUR_ENDPOINT_KEY" method="POST">
<label>Name <input name="name" required></label>
<label>Email <input type="email" name="email" required></label>
<label>Message <textarea name="message" required></textarea></label>
<button type="submit">Send message</button>
</form>For a JavaScript form that stays on the page, use the HTML above and add this handler. For React or Next.js, use the framework guides below.
JavaScript submission handler
const form = document.querySelector("#contact-form");
const status = document.createElement("p");
status.setAttribute("role", "status");
form.after(status);
form.addEventListener("submit", async (event) => {
event.preventDefault();
const button = form.querySelector('button[type="submit"]');
button.disabled = true;
status.textContent = "Sending...";
try {
const data = Object.fromEntries(new FormData(form).entries());
const response = await fetch("https://api.smartformify.com/fe/YOUR_ENDPOINT_KEY", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ data }),
});
const result = await response.json();
if (!response.ok || !result.success) {
throw new Error(result.message || "Submission failed. Please try again.");
}
if (result.data?.redirect_url) {
window.location.assign(result.data.redirect_url);
return;
}
status.textContent = "Thanks, your message has been received.";
form.reset();
} catch (error) {
status.textContent = error.message || "Could not send. Please try again.";
} finally {
button.disabled = false;
}
});Submit a test from the published domain. Confirm that it appears in Responses and that the configured notification arrives. A success animation alone is not proof that a response was saved.
Remove temporary preview domains when testing is complete. Check your form again after changing the generated website.