# Custom Appointment Booking Scenario from Booking Forms

**URL:** <https://forum.wixstudio.com/t/custom-appointment-booking-scenario-from-booking-forms/70891>\
**Category:** Ask the community\
**Tags:** wix-bookings, bookings, data, partners, wix-apps-market\
**Created:** [May 13, 2025, 11:23am UTC](https://forum.wixstudio.com/t/custom-appointment-booking-scenario-from-booking-forms/70891 "2025-05-13T11:23:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hello59727](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/hello59727/32/107411_2.png) [@hello59727](https://forum.wixstudio.com/u/hello59727)\
**Post date:** [May 13, 2025, 11:23am UTC](https://forum.wixstudio.com/t/custom-appointment-booking-scenario-from-booking-forms/70891/1 "2025-05-13T11:23:05Z")

</div>

**Question:**  
Is there something i’ve missed in my code?

**Product:**  
Wix Bookings

**What are you trying to achieve:**  
Choirs For Good run choirs that we’d like to be booked for events etc. I’m trying to use Wix appointments to help me with this. But I need to custom code it as timings and addresses for each event will differ (rather than picking pre-defined slots). I have started with the below code from a form input, but dont seem to be getting any results. Am I missing something?

**What have you already tried:**  
[Share resources, forum topics, articles, or tutorials you’ve already used to try and answer your question.]

**Additional information:**

// import wixData from “@wix/data”;  
// import { bookings,services } from ‘wix-bookings.v2’;  
import { bookings, services, availabilityCalendar } from “@wix/bookings”;

const createBooking = async (choirSlug, contactDetails, date, startTime, endTime) =\> {  
const availableServices = await services.queryServices({ “type”: “APPOINTMENT” }).eq(‘mainSlug.name’, choirSlug).find()  
const service = availableServices.items[0]  
const startDate = new Date(date.toString().replace(‘00:00:00’, startTime))  
const endDate = new Date(date.toString().replace(‘00:00:00’, endTime))

```
console.log({ date, startTime, endTime, startDate, endDate })

const query = {
    filter: {
        serviceId: service._id,
        startDate,
        endDate,

    },
}

const availableSlots = await availabilityCalendar.queryAvailability(query)

console.log({ availableServices })
console.log({ availableSlots })

const firstSlot = availableSlots.availabilityEntries && availableSlots.availabilityEntries.length ? availableSlots.availabilityEntries[0].slot : null

if (!firstSlot) {
    return
}

const booking = await bookings.createBooking({
    contactDetails,
    startDate,
    endDate,
    bookedEntity: {
        slot: firstSlot,
    },
    totalParticipants: 1,
    

    
});

console.log({ booking });

```

}

$w.onReady(function () {  
// Set up event handler for form submission

```
$w('#bookachoir').onWixFormSubmit(async () => {
    try {
        const startDate = $w('#eventdateinput').value
        const choirSlug = $w('#dropdown1').value
        const startTime = $w('#timefrominput').value
        const endTime = $w('#timetillinput').value

        const contactDetails = {
            firstName: $w('#firstnameinput').value,
            lastName: $w('#lastnameinput').value,
            emails: [$w('#emailinput').value],
            phones: [$w('#phoneinput').value],
        }

        await createBooking(choirSlug, contactDetails, startDate, startTime, endTime)
    } catch (e) {
        console.log(e)
    }

    return true
});

```

});

 ![Screenshot 2025-05-13 at 12.23.51](https://us1.discourse-cdn.com/wix/original/3X/d/f/df7e7e5caa25a7d6a8a72020a54f4b8fb265bc1f.jpeg)
