Turn off Automated Emails and send my own confirmation Emails for Bookings.

Hi. I built a quick booking system very similar to this example: https://www.wix.com/corvid/example/quick-book-and-pending-appointments

So basically, the site visitor inputs the information on the main page, which is sent to the database and to a pending appointments admin page, where I can approve or dismiss his request. If I click the approve button, as on the example, the code books the slot chosen by the client.

Bookings has automated emails once a booking is made, but I wanted to make a nice design for my booking confirmation email, something more on the lines of the Wix Triggered Email designs. Can I then disable the Automated Emails and edit the appointments admin page code mentioned above to send an email once i approve and the booking is confirmed?

I thought of sending a TriggeredEmail or even something like emailjs.com, once the booking is confirmed. Is that possible?

I saw in another thread that it is possible to send triggered emails to not-loggedIn (in WIX system) users if I have the user information ( https://www.wix.com/corvid/forum/main/comment/5b5f2cc4a84b0300148ae8f6 ), which I do since I have the client’s booking information, with the following code:

create contactObject with firstName, lastName, email, ...
wix-createContact(contactObject) => contactId [REMEMBER This For your Triggered email}
then
wix-crm.emailContact('triggeredEmailName", contactId [from createContact])

Or even, another option, instead of TriggeredEmails, is to use emailjs.com as in this example (https://girizano.wixsite.com/codecorner/post/send-email-thru-gmail-and-others-in-wix-code), but i’m having trouble to put it all together, how to populate the email with the booking info and then sending email in the code I already have…and then again I would need to disable the Automated Emails Wix sends or else the client would receive 2 emails.

Here’s the code that approves the request on my appointments admin page:

async function approveRequest(pendingRequest, index) {
 const slot = pendingRequest.requestedSlot;
 const service = await getService(slot.serviceId);
 let formFields = [{
            _id: getFieldId(service, "Nome"),
            value: pendingRequest.nome
        },
        {
            _id: getFieldId(service, "Email"),
            value: pendingRequest.email
        },
        {
            _id: getFieldId(service, "Nascimento"),
            value: pendingRequest.dataNascimento
        },
        {
            _id: getFieldId(service, "WhatsApp"),
            value: pendingRequest.whatsapp
        },
    ];

const bookingInfo = {
        slot,
        formFields
    };

 const bookingResponse = await wixBookings.checkoutBooking(bookingInfo);
 
 if (bookingResponse.status === "Confirmed") {
        pendingRequest.status = "APPROVED";
 await wixData.update("pendingAppointments", pendingRequest);
        refreshData();
    } 
 else {
            $w("#approveButton").enable();
    }
}

Does anyone have an input, how I could go about on this issue?


Here’s the full page code, if anyone needs to take a look, but it’s quite similar to the example I mentioned in the beginning.

import wixData from "wix-data";
import wixBookings from "wix-bookings";
import wixLocation from "wix-location";

$w.onReady(function () {
    $w("#pendingRequestsDataset").onReady(() => {
 if ($w("#pendingRequestsDataset").getTotalCount() === 0) {
            $w("#noPendingRequests").show();
        }
    });
});

export function requestsRepeater_itemReady($item, itemData, index) {
 const slot = itemData.requestedSlot;
 const start = new Date(slot.startDateTime);
    $item("#date").text = getDate(start);
    $item("#time").text = getTimeOfDay(start);

    $item("#dismissButton").onClick(async () => {
        $item("#dismissButton").disable();
        $item("#approveButton").disable();
 await dismissRequest(itemData, index);
    });
    $item("#approveButton").onClick(async () => {
        $item("#dismissButton").disable();
        $item("#approveButton").disable();
 await approveRequest(itemData, index);
    });
}

export function dismissedRequests_itemReady($item, itemData, index) {
    $item("#emailButton").onClick(() => {
 const subject = "Thanks For Getting in Touch";
        wixLocation.to(`mailto:${itemData.email}?subject=${subject}`);
    });
}

async function dismissRequest(pendingRequest, index) {
    pendingRequest.status = "DISMISSED";
 await wixData.update("pendingAppointments", pendingRequest);
    refreshData();
}

async function approveRequest(pendingRequest, index) {
 const slot = pendingRequest.requestedSlot;
 const service = await getService(slot.serviceId);
 let formFields = [{
            _id: getFieldId(service, "Nome"),
            value: pendingRequest.nome
        },
        {
            _id: getFieldId(service, "Email"),
            value: pendingRequest.email
        },
        {
            _id: getFieldId(service, "Nascimento"),
            value: pendingRequest.dataNascimento
        },
        {
            _id: getFieldId(service, "WhatsApp"),
            value: pendingRequest.whatsapp
        },
    ];

const bookingInfo = {
        slot,
        formFields
    };

 const bookingResponse = await wixBookings.checkoutBooking(bookingInfo);
 
 if (bookingResponse.status === "Confirmed") {
        pendingRequest.status = "APPROVED";
 await wixData.update("pendingAppointments", pendingRequest);
        refreshData();
    } 
 else {
            $w("#approveButton").enable();
    }
}

function getService(id) {
 return wixData.get("Bookings/Services", id);
}

function getFieldId(service, label) {
 return service.form.fields.filter(field => field.label === label)[0]._id;
}

function refreshData() {
    $w("#pendingRequestsDataset").refresh().then(() => {
 if ($w("#pendingRequestsDataset").getTotalCount() === 0) {
            $w("#noPendingRequests").show();
        }
    });
    $w("#dismissedRequestsDataset").refresh();
}

function getTimeOfDay(date) {
 return date.toLocaleTimeString([], { hour: "2-digit", minute:"2-digit"});
}

function getDate(date) {
 return  date.toLocaleDateString("en-GB", {day: "numeric", month: "numeric", year: "numeric" });
}

If you use a Wix app then you can’t turn off the automated emails that get sent by them.

With Wix Bookings, you can edit them to suit your own needs.
https://support.wix.com/en/article/customizing-your-confirmation-email-in-wix-bookings-7247354

https://support.wix.com/en/wix-bookings/customizing-wix-bookings-pages
https://support.wix.com/en/article/request-customize-the-email-address-wix-bookings-notifications-are-sent-from

I understand you can customize the content. But I wanted to customize the design also, something a bit more like the look of the brand. Something like these two examples, or even like Wix’s own Triggered Emails, that’s more of the design I was looking for:

Is there a way to customize the Automated Email’s design?

@buenok I can´r help you much with Wix Bookings, since it is out of my realm, never used it. I wrote that article about email.js. What´s you problem? If it is true what @givemeawhisky says (and it usually is), meaning you can´t turn off emails, maybe your only resort is to do this:

  1. adapt the standard email to something like saying “Thanks, we will confirm your slot in a minute”
  2. send your own email directly afterwards using emailjs.com (or, as Quentin contributed lately, by going directly to gmail, bypassing the need for emailjs).

@giri-zano Thanks for the idea. I hadn’t thought about that. I guess it’s the best way around for now.

When you say to go directly to Gmail, can that be automated or would I do that manually?

No, it´s automated, from code. Just search for gmail email on this very forum, you´ll find it. It´s inside a thread from Luigi, if memory serves me right. @yisrael-wix contributed a solution for the deprecation I discovered when I tried it.
The diff between the 2 is this: emailjs offers a unified interface onto many, many email providers (outlook, gmail, yahoo, mailgun,etc) without changing anything in your code. @plomteuxquentin made a contribution ONLY for gmail. But … it´s free, within limits.

@giri-zano The code I produce can be use to send email via any SMTP provider. Google is the most complex (due to Oauth2 authentication) and requested. But if you discard Oauth2 is should be working with pretty much any provider :

  1. Here is how to configure your own

  2. Here is the list of well-known config

unfortunately, I don’t have time to correct the example I provided but will do on the next job that requires smtp mailing

@giri-zano

Yes unfortunately it is the same with most of the Wix apps that you will get an automated email sent out by Wix even if you have set up your own Wix Automation or triggered email.

I know Wix Forms does along with Wix Paid Plans, Wix Events and Wix Bookings which you can customise to a degree etc, however the default automatic one from Wix itself can’t be turned off.

I asked Wix Support about it at the start of the year and still nothing has changed.

(Wix Support) 
January 15, 2019 5:30 AM (UTC-05:00) 
    
Hi,
Thank you for contacting Wix Customer Solutions! 
I see what you're referring to. Another email cannot be switched off indeed. 
 
The email is automatically sent and is designed to notify your members......

Yep, you´re right. Humbly stand corrected. Will rephrase: " @plomteuxquentin contributed a solution which, in it´s current version, does gmail (but not limited to). ". PS Did you hear anything back from Wix about the backup thing we proposed on the Expert Forum? I never did.

@giri-zano np. And no, I did not heard anything :slight_smile: