Installing AI Chat on Webflow
Additional instructions for installing Spara through Webflow
Last updated
<script>
// Redirect to a dynamically built url after form submission
document.addEventListener("DOMContentLoaded", function() {
$(document).ajaxComplete(function( event, xhr, settings ) {
if(settings.url.includes("https://webflow.com/api/v1/form/")){
const isSuccessful = xhr.status === 200;
// This is the name of the form in Webflow. Give it a more meaningful name and then change here as well.
const formName = "Form";
const isRightForm = settings.data.includes(formName.replaceAll(' ', '+'));
console.log(isSuccessful);
console.log(isRightForm);
if(isRightForm && isSuccessful){
const email = $('#Email-7').val();
const firstName = $('#Full-Name-4').val();
const companyName = $('#Company-Name-4').val();
window.location = '/chat?lead_email=' + email + '&lead_first_name=' + firstName + '&lead_company_name=' + companyName;
} else if(!isRightForm) {
console.log('Not the form we want. Do nothing.');
}
}
})
});
</script>