diff --git a/.DS_Store b/.DS_Store
index 88410c6..599ba17 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e985853
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.vercel
diff --git a/api/saveEmail.js b/api/saveEmail.js
deleted file mode 100644
index 0043be6..0000000
--- a/api/saveEmail.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import { MongoClient } from 'mongodb';
-
-const uri = process.env.MONGODB_URI;
-let client;
-let clientPromise;
-
-if (!clientPromise) {
- client = new MongoClient(uri, {
- useNewUrlParser: true,
- useUnifiedTopology: true,
- });
- clientPromise = client.connect();
-}
-
-export default async function handler(req, res) {
- console.log('Handler triggered'); // Log when handler is called
-
- if (req.method === 'POST') {
- const { email } = req.body;
-
- if (!email) {
- console.error('No email provided');
- res.status(400).json({ error: 'Email is required' });
- return;
- }
-
- try {
- console.log('Connecting to MongoDB...');
- const client = await clientPromise;
-
- console.log('Connected to MongoDB');
- const database = client.db('botsmann');
- const emails = database.collection('emails');
-
- console.log('Inserting email:', email);
- const result = await emails.insertOne({ email });
-
- console.log('Insert Result:', result); // Log insert result
- res.status(200).json({ message: 'Email saved successfully' });
- } catch (error) {
- console.error('Error while saving email:', error); // Detailed error
- res.status(500).json({ error: `Failed to save email: ${error.message}` });
- }
- } else {
- console.error('Invalid method:', req.method);
- res.setHeader('Allow', ['POST']);
- res.status(405).end(`Method ${req.method} Not Allowed`);
- }
-}
diff --git a/api/saveEmail.js.save b/api/saveEmail.js.save
deleted file mode 100644
index e256c82..0000000
--- a/api/saveEmail.js.save
+++ /dev/null
@@ -1,22 +0,0 @@
-export default async function handler(req, res) {
- if (req.method === 'POST') {
- const { email } = req.body;
-
- if (!email) {
- res.status(400).json({ error: 'Email is required' });
- return;
- }
-
- try {
- // For now, we will simply log the email (replace this with actual database logic)
- console.log('Received email:', email);
- res.status(200).json({ message: 'Email saved successfully' });
- } catch (error) {
- res.status(500).json({ error: 'Failed to save email' });
- }
- } else {
- res.setHeader('Allow', ['POST']);
- res.status(405).end(`Method ${req.method} Not Allowed`);
- }
-}
-
diff --git a/api/submit.js b/api/submit.js
new file mode 100644
index 0000000..ba1be06
--- /dev/null
+++ b/api/submit.js
@@ -0,0 +1,111 @@
+const { MongoClient } = require('mongodb');
+const nodemailer = require('nodemailer');
+
+// Email configuration
+const transporter = nodemailer.createTransport({
+ service: 'gmail',
+ auth: {
+ user: process.env.EMAIL_USER,
+ pass: process.env.EMAIL_APP_PASSWORD
+ }
+});
+
+// Validation function
+function validateForm(data) {
+ const errors = [];
+
+ if (!data.name || data.name.length < 2) {
+ errors.push('Name must be at least 2 characters long');
+ }
+
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+ if (!data.email || !emailRegex.test(data.email)) {
+ errors.push('Please enter a valid email address');
+ }
+
+ if (!data.message || data.message.length < 10) {
+ errors.push('Message must be at least 10 characters long');
+ }
+
+ return errors;
+}
+
+export default async function handler(req, res) {
+ if (req.method !== 'POST') {
+ return res.status(405).json({ message: 'Method not allowed' });
+ }
+
+ try {
+ // Validate input
+ const validationErrors = validateForm(req.body);
+ if (validationErrors.length > 0) {
+ return res.status(400).json({
+ success: false,
+ errors: validationErrors
+ });
+ }
+
+ // Connect to MongoDB
+ const client = await MongoClient.connect(process.env.MONGODB_URI);
+ const db = client.db('botsmann');
+
+ const { name, email, message } = req.body;
+
+ // Save to database
+ const submission = await db.collection('consultations').insertOne({
+ name,
+ email,
+ message,
+ createdAt: new Date()
+ });
+
+ // Send notification email
+ const mailOptions = {
+ from: process.env.EMAIL_USER,
+ to: process.env.NOTIFICATION_EMAIL,
+ subject: 'New Consultation Request - Botsmann',
+ html: `
+
New Consultation Request
+ Name: ${name}
+ Email: ${email}
+ Message:
+ ${message}
+
+ Received on: ${new Date().toLocaleString()}
+ `
+ };
+
+ await transporter.sendMail(mailOptions);
+
+ // Send confirmation email to user
+ const userMailOptions = {
+ from: process.env.EMAIL_USER,
+ to: email,
+ subject: 'Thank you for contacting Botsmann',
+ html: `
+ Thank you for reaching out!
+ Dear ${name},
+ We've received your consultation request and will get back to you shortly.
+ Your message:
+ ${message}
+ Best regards,
The Botsmann Team
+ `
+ };
+
+ await transporter.sendMail(userMailOptions);
+
+ await client.close();
+
+ res.status(200).json({
+ success: true,
+ message: 'Submission successful'
+ });
+ } catch (error) {
+ console.error('Submission error:', error);
+ res.status(500).json({
+ success: false,
+ message: 'Error submitting form',
+ error: error.message
+ });
+ }
+}
\ No newline at end of file
diff --git a/app.yaml b/app.yaml
new file mode 100644
index 0000000..b389630
--- /dev/null
+++ b/app.yaml
@@ -0,0 +1,10 @@
+runtime: nodejs16
+
+env_variables:
+ MONGODB_URI: "your_mongodb_connection_string"
+
+handlers:
+ - url: /.*
+ secure: always
+ redirect_http_response_code: 301
+ script: auto
\ No newline at end of file
diff --git a/form.js b/form.js
new file mode 100644
index 0000000..566d9ad
--- /dev/null
+++ b/form.js
@@ -0,0 +1,88 @@
+async function validateFormClient(formData) {
+ const errors = [];
+
+ if (formData.name.length < 2) {
+ errors.push('Name must be at least 2 characters long');
+ }
+
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+ if (!emailRegex.test(formData.email)) {
+ errors.push('Please enter a valid email address');
+ }
+
+ if (formData.message.length < 10) {
+ errors.push('Message must be at least 10 characters long');
+ }
+
+ return errors;
+}
+
+async function submitForm(event) {
+ event.preventDefault();
+
+ const form = event.target;
+ const submitButton = form.querySelector('button[type="submit"]');
+ const statusDiv = document.getElementById('formStatus');
+
+ // Clear previous status messages
+ statusDiv.innerHTML = '';
+
+ const formData = {
+ name: form.name.value.trim(),
+ email: form.email.value.trim(),
+ message: form.message.value.trim()
+ };
+
+ // Client-side validation
+ const validationErrors = await validateFormClient(formData);
+ if (validationErrors.length > 0) {
+ statusDiv.innerHTML = `
+
+ ${validationErrors.map(err => `• ${err}`).join('
')}
+
+ `;
+ return;
+ }
+
+ // Show loading state
+ submitButton.disabled = true;
+ submitButton.innerHTML = `
+
+ Sending...
+ `;
+
+ try {
+ const response = await fetch('/api/submit', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(formData)
+ });
+
+ const result = await response.json();
+
+ if (response.ok) {
+ // Success
+ statusDiv.innerHTML = `
+
+
Thank you! Your message has been sent successfully.
+
We'll get back to you at ${formData.email} soon.
+
+ `;
+ form.reset();
+ } else {
+ throw new Error(result.errors ? result.errors.join(', ') : result.message);
+ }
+ } catch (error) {
+ statusDiv.innerHTML = `
+
+
Error: ${error.message}
+
Please try again or contact us directly.
+
+ `;
+ } finally {
+ submitButton.disabled = false;
+ submitButton.innerHTML = 'Submit';
+ }
+}
\ No newline at end of file
diff --git a/index.html b/index.html
index 49647e7..6106b2f 100644
--- a/index.html
+++ b/index.html
@@ -1,38 +1,136 @@
-
- Tailored AI Assistants & Robots
+ Botsmann | Personal AI Solutions
+
-
-
-
-
-