examples/amazon-lex-with-lambda.js
function getAvailabilities(date) {
    const dayOfWeek = parseLocalDate(date).getDay();
    const availabilities = [];
    const availableProbability = 0.3;
    if (dayOfWeek === 1) {
        let startHour = 10;
        while (startHour <= 16) {
            if (Math.random() < availableProbability) {
                // Add an availability window for the given hour, with duration determined by another random number.
                const appointmentType = getRandomInt(1, 4);
                if (appointmentType === 1) {
                    availabilities.push(`${startHour}:00`);
                } else if (appointmentType === 2) {
                    availabilities.push(`${startHour}:30`);
                } else {
                    availabilities.push(`${startHour}:00`);
                    availabilities.push(`${startHour}:30`);
                }
            }
            startHour++;
        }
    }
    if (dayOfWeek === 3 || dayOfWeek === 5) {
        availabilities.push('10:00');
        availabilities.push('16:00');
        availabilities.push('16:30');
    }
    return availabilities;
}
function getAvailabilities(date) {
    const dayOfWeek = parseLocalDate(date).getDay();
    const availabilities = [];
    const availableProbability = 0.3;
    if (dayOfWeek === 1) {
        let startHour = 10;
        while (startHour <= 16) {
            if (Math.random() < availableProbability) {
                // Add an availability window for the given hour, with duration determined by another random number.
                const appointmentType = getRandomInt(1, 4);
                if (appointmentType === 1) {
                    availabilities.push(`${startHour}:00`);
                } else if (appointmentType === 2) {
                    availabilities.push(`${startHour}:30`);
                } else {
                    availabilities.push(`${startHour}:00`);
                    availabilities.push(`${startHour}:30`);
                }
            }
            startHour++;
        }
    }
    if (dayOfWeek === 3 || dayOfWeek === 5) {
        availabilities.push('10:00');
        availabilities.push('16:00');
        availabilities.push('16:30');
    }
    return availabilities;
}
function getAvailabilities ( date ) { const dayOfWeek = parseLocalDate ( date ) . getDay ( ) ; const availabilities = [ ] ; const availableProbability = 0.3 ; if ( dayOfWeek === 1 ) { let startHour = 10 ; while ( startHour <= 16 ) { if ( Math . random ( ) < availableProbability ) { // Add an availability window for the given hour, with duration determined by another random number. const appointmentType = getRandomInt ( 1 , 4 ) ; if ( appointmentType === 1 ) { availabilities . push ( ` ${ startHour } ` ) ; } else if ( appointmentType === 2 ) { availabilities . push ( ` ${ startHour } ` ) ; } else { availabilities . push ( ` ${ startHour } ` ) ; availabilities . push ( ` ${ startHour } ` ) ; } } startHour ++ ; } } if ( dayOfWeek === 3 || dayOfWeek === 5 ) { availabilities . push ( '10:00' ) ; availabilities . push ( '16:00' ) ; availabilities . push ( '16:30' ) ; } return availabilities ; }
Helper function which in a full implementation would  feed into a backend API to provide query schedule availability.
The output of this function is an array of 30 minute periods of availability, expressed in ISO-8601 time format.

In order to enable quick demonstration of all possible conversation paths supported in this example, the function
returns a mixture of fixed and randomized results.

On Mondays, availability is randomized; otherwise there is no availability on Tuesday / Thursday and availability at
10:00 - 10:30 and 4:00 - 5:00 on Wednesday / Friday.
Helper function which in a full implementation would feed into a backend API to provide query schedule availability . The output of this function is an array of 30 minute periods of availability expressed in ISO - 8601 time format .