अपनी AI बुकिंग वेबसाइट पर ईमेल नोटिफिकेशन जोड़ें

Supabase, Resend और Edge Functions का उपयोग करके बुकिंग पुष्टिकरण ईमेल और मालिक अलर्ट भेजें।

रोडमैप और संसाधन

यहाँ नए हैं? पहले यहाँ से शुरू करें

यह गाइड AI बुकिंग वेबसाइट प्रोजेक्ट को स्वचालित ईमेल नोटिफिकेशन के साथ अपग्रेड करती है। यदि आपने अभी तक बुकिंग वेबसाइट नहीं बनाई है, तो पहले मुख्य गाइड से शुरू करें।

AI के साथ एक बुकिंग वेबसाइट बनाएँ

मुख्य गाइड खोलें

MAIN GUIDE

https://profitstudio.app/video/build-booking-website-ai

बुकिंग ईमेल के लिए Resend सेट अप करें

अपना Resend अकाउंट बनाएँ और कॉन्फ़िगर करें

Resend खोलें

https://resend.com/

Resend अकाउंट बनाएँ Resend API की जनरेट करें API की को कॉपी करके सुरक्षित रूप से सेव करें

महत्वपूर्ण

Resend API की को निजी रखें। इसे कभी भी फ्रंटएंड कोड में न जोड़ें और न ही सार्वजनिक रूप से साझा करें।

अपना भेजने वाला डोमेन जोड़ें और सत्यापित करें

अपनी बुकिंग वेबसाइट का डोमेन जोड़ें सबसे नज़दीकी रीजन चुनें Resend से DNS रिकॉर्ड कॉपी करें अपने डोमेन प्रोवाइडर में रिकॉर्ड जोड़ें Resend पर लौटें और पुष्टि करें कि डोमेन सत्यापित हो गया है

आपके डोमेन प्रोवाइडर के आधार पर DNS सत्यापन में कुछ मिनट या उससे अधिक समय लग सकता है।

बुकिंग ईमेल फ़ंक्शन बनाएँ

बुकिंग ईमेल Edge Function बनाएँ

Supabase खोलें

https://supabase.com/?utm_source=partner&utm_medium=social&utm_campaign=supasquad&dub_id=faVfKdcLWvKCbYNp

अपना Supabase प्रोजेक्ट खोलें Edge Functions खोलें ब्राउज़र एडिटर से नया फ़ंक्शन बनाएँ फ़ंक्शन का नाम `send-booking-email` रखें डिफ़ॉल्ट स्टार्टर कोड हटाएँ

फ़ंक्शन कोड को कस्टमाइज़ करें और जोड़ें

मालिक का ईमेल दर्ज करें सत्यापित Resend डोमेन दर्ज करें भेजने वाले व्यवसाय का नाम दर्ज करें ज़रूरत हो तो ईमेल टेम्पलेट कस्टमाइज़ करें जनरेट किया गया फ़ंक्शन कोड कॉपी करके पेस्ट करें

बुकिंग ईमेल फ़ंक्शन

import { serve } from "https://deno.land/std/http/server.ts"; serve(async (req) => { try { const body = await req.json(); const record = body.record || {}; const resendKey = Deno.env.get("RESEND_API_KEY"); const supabaseUrl = Deno.env.get("SUPABASE_URL"); const supabaseServiceRoleKey = Deno.env.get("SUPABASE_SERVICE_ROLE_KEY"); if (!resendKey) { return new Response( JSON.stringify({ error: "Missing RESEND_API_KEY secret" }), { status: 500, headers: { "Content-Type": "application/json" }, } ); } const ownerEmail = "YOUR_OWNER_EMAIL"; const customerEmail = record.email || ""; const customerName = record.full_name || record.name || "Customer"; const phone = record.phone || ""; const appointmentDate = record.appointment_date || record.date || ""; const startTime = record.start_time || record.time || ""; const endTime = record.end_time || ""; const notes = record.notes || ""; const status = record.status || "New"; let serviceName = record.service_name || record.service || record.service_title || ""; // If the appointment only has service_id, fetch the service name from the services table if (!serviceName && record.service_id && supabaseUrl && supabaseServiceRoleKey) { try { const serviceId = encodeURIComponent(record.service_id); const serviceResponse = await fetch( `${supabaseUrl}/rest/v1/services?id=eq.${serviceId}&select=name`, { method: "GET", headers: { apikey: supabaseServiceRoleKey, Authorization: `Bearer ${supabaseServiceRoleKey}`, "Content-Type": "application/json", }, } ); const serviceData = await serviceResponse.json(); if (Array.isArray(serviceData) && serviceData.length > 0) { serviceName = serviceData[0].name || ""; } } catch (_serviceError) { serviceName = ""; } } if (!serviceName) { serviceName = "Appointment"; } // 1) Email to business owner const ownerResponse = await fetch("https://api.resend.com/emails", { method: "POST", headers: { Authorization: `Bearer ${resendKey}`, "Content-Type": "application/json", }, body: JSON.stringify({ from: "Bookings <bookings@YOUR_DOMAIN_NAME>", to: [ownerEmail], subject: "OWNER_NOTIFICATION_SUBJECT", html: ` <h2>OWNER_NOTIFICATION_HEADING</h2> <p>OWNER_NOTIFICATION_INTRO</p> <p><b>Customer Name:</b> ${customerName}</p> <p><b>Email:</b> ${customerEmail}</p> <p><b>Phone:</b> ${phone}</p> <p><b>Service:</b> ${serviceName}</p> <p><b>Date:</b> ${appointmentDate}</p> <p><b>Start Time:</b> ${startTime}</p> <p><b>End Time:</b> ${endTime}</p> <p><b>Notes:</b> ${notes}</p> <p><b>Status:</b> ${status}</p> `, }), }); const ownerData = await ownerResponse.json(); // 2) Email to customer let customerData = null; if (customerEmail) { const customerResponse = await fetch("https://api.resend.com/emails", { method: "POST", headers: { Authorization: `Bearer ${resendKey}`, "Content-Type": "application/json", }, body: JSON.stringify({ from: "YOUR_BUSINESS_NAME <bookings@YOUR_DOMAIN_NAME>", to: [customerEmail], subject: "CUSTOMER_CONFIRMATION_SUBJECT", html: ` <h2>CUSTOMER_CONFIRMATION_HEADING</h2> <p>Hi ${customerName},</p> <p>CUSTOMER_CONFIRMATION_INTRO</p> <p><b>Service:</b> ${serviceName}</p> <p><b>Date:</b> ${appointmentDate}</p> <p><b>Start Time:</b> ${startTime}</p> <p><b>End Time:</b> ${endTime}</p> <p>If you need to make any changes, please contact us before your appointment.</p> <p>CUSTOMER_CONFIRMATION_CLOSING</p> `, }), }); customerData = await customerResponse.json(); } return new Response( JSON.stringify({ success: true, ownerEmailSent: ownerData, customerEmailSent: customerData, }), { headers: { "Content-Type": "application/json" }, } ); } catch (error) { return new Response( JSON.stringify({ success: false, error: String(error), }), { status: 500, headers: { "Content-Type": "application/json" }, } ); } });

मालिक का ईमेल

owner@example.com

सत्यापित Resend डोमेन

yourdomain.com

भेजने वाले का व्यवसाय नाम

ब्राइट डेंटल क्लिनिक

मालिक का ईमेल विषय

मालिक का ईमेल हेडिंग

मालिक का ईमेल परिचय टेक्स्ट

ग्राहक ईमेल विषय

ग्राहक ईमेल हेडिंग

ग्राहक ईमेल परिचय टेक्स्ट

ग्राहक ईमेल समापन टेक्स्ट

फ़ंक्शन को डिप्लॉय और कॉन्फ़िगर करें

फ़ंक्शन डिप्लॉय करें फ़ंक्शन सेटिंग्स खोलें `Verify JWT With Legacy Secret` बंद करें बदलाव सेव करें Webhook सेटअप के लिए फ़ंक्शन का endpoint URL कॉपी करके सेव करें

महत्वपूर्ण

“Verify JWT With Legacy Secret” को बंद करें ताकि Database Webhook फ़ंक्शन को कॉल कर सके।

Supabase में Resend API Key जोड़ें

Resend API की को Supabase सीक्रेट के रूप में जोड़ें

Edge Function Secrets खोलें नया सीक्रेट बनाएँ नाम `RESEND_API_KEY` सेट करें Resend API की पेस्ट करें सीक्रेट सेव करें

महत्वपूर्ण

सीक्रेट का नाम बिल्कुल `RESEND_API_KEY` ही रखें। किसी भी टाइपिंग गलती से फ़ंक्शन Resend तक नहीं पहुँच पाएगा।

ईमेल को नई बुकिंग से जोड़ें

बुकिंग ईमेल Webhook बनाएँ

जब भी कोई नई अपॉइंटमेंट जुड़े, बुकिंग ईमेल फ़ंक्शन को ट्रिगर करें।

Integrations Database Webhooks

Database Webhooks खोलें Database Webhooks सक्षम करें नया webhook बनाएँ इसका नाम `send-booking-email-webhook` रखें `public.appointments` टेबल चुनें इवेंट के रूप में `Insert` चुनें प्रकार `HTTP Request` ही रहने दें रिक्वेस्ट मेथड के रूप में `POST` का उपयोग करें Edge Function का endpoint URL पेस्ट करें webhook बनाएँ

बुकिंग ईमेल सिस्टम का परीक्षण करें

पूरे बुकिंग ईमेल फ़्लो का परीक्षण करें

पूरे बुकिंग फ़्लो का परीक्षण करें और पुष्टि करें कि दोनों ईमेल सही तरीके से डिलीवर हो रहे हैं।

लाइव बुकिंग वेबसाइट खोलें एक टेस्ट अपॉइंटमेंट सबमिट करें पुष्टि करें कि बुकिंग Supabase में सेव हो गई है ग्राहक को भेजा गया पुष्टिकरण ईमेल जाँचें मालिक को भेजा गया सूचना ईमेल जाँचें दोनों ईमेल में बुकिंग विवरण सही होने की पुष्टि करें पुष्टि करें कि बुकिंग एडमिन डैशबोर्ड में दिख रही है