✦ jqxScheduler AI

Smart scheduling

Describe what you need in plain language. The Scheduler reads everyone's real availability, proposes genuinely open times (never an invented one), and books on your confirm. It can also spot double-bookings and reschedule them in one click.

find 30 min in Room A tomorrow afternoon find 1 hour in Room B this week find 45 minutes before Friday
Ask for a time above, or click Resolve conflicts — there's an intentional double-booking today in Room A.

jQuery Scheduler: AI Smart Scheduling

jqxScheduler AI Smart Scheduling - find open times in plain language and resolve conflicts.

A live JavaScript/jQuery example of jqxScheduler, the jQWidgets Scheduler component, with its complete source code below. It is one of 45 jqxScheduler demos for jQuery.

jqxScheduler API used in this demo

Source code

To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $. Getting started with jqxScheduler shows the setup step by step.

The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxbuttons.js, jqxscrollbar.js, jqxdata.js, jqxdate.js, jqxscheduler.js, jqxscheduler.api.js, jqxdatetimeinput.js, jqxmenu.js, jqxcalendar.js, jqxtooltip.js, jqxwindow.js, jqxcheckbox.js, jqxlistbox.js, jqxdropdownlist.js, jqxnumberinput.js, jqxradiobutton.js, jqxinput.js, jqxwidgets.ai.js, jqxscheduler.ai.js.

It also loads helper scripts of this demo site, which are not part of the library: scheduler-ai-mock.js.

script.js

$(document).ready(function () {
    var today = new Date(); today.setHours(0, 0, 0, 0);
    function at(off, h, m) { var d = new Date(today); d.setDate(d.getDate() + off); d.setHours(h, m || 0, 0, 0); return d; }
    var appts = [
        { id: '1', subject: 'Standup', start: at(0, 9, 0), end: at(0, 9, 30), calendar: 'Room A' },
        { id: '2', subject: 'Design review', start: at(0, 11, 0), end: at(0, 12, 0), calendar: 'Room A' },
        { id: '7', subject: 'Budget sync', start: at(0, 11, 30), end: at(0, 12, 30), calendar: 'Room A' },
        { id: '3', subject: '1:1 with Sam', start: at(1, 10, 0), end: at(1, 10, 30), calendar: 'Room B' },
        { id: '4', subject: 'Sprint planning', start: at(1, 14, 0), end: at(1, 15, 30), calendar: 'Room A' },
        { id: '5', subject: 'Client call', start: at(2, 13, 0), end: at(2, 14, 0), calendar: 'Room B' },
        { id: '6', subject: 'Retro', start: at(3, 15, 0), end: at(3, 16, 0), calendar: 'Room A' }
    ];
    var source = new $.jqx.dataAdapter({
        dataType: 'array', id: 'id', localData: appts,
        dataFields: [{ name: 'id', type: 'string' }, { name: 'subject', type: 'string' }, { name: 'start', type: 'date' }, { name: 'end', type: 'date' }, { name: 'calendar', type: 'string' }]
    });
    var resources = new $.jqx.dataAdapter({ dataType: 'array', dataFields: [{ name: 'calendar', type: 'string' }], localData: [{ calendar: 'Room A' }, { calendar: 'Room B' }] });

    $('#scheduler').jqxScheduler({
        width: '100%', height: 380, source: source, view: 'weekView', views: ['dayView', 'weekView'],
        date: new $.jqx.date(today.getFullYear(), today.getMonth() + 1, today.getDate()),
        resources: { colorScheme: 'scheme05', dataField: 'calendar', source: resources },
        appointmentDataFields: { from: 'start', to: 'end', id: 'id', subject: 'subject', resourceId: 'calendar' },
        aiSendRequest: jqxSchedulerAIMock,
        ready: function () {
            // the day starts at the working day
            $('#scheduler').jqxScheduler('scrollToTime', 8);
        }
    });

    var fmt = function (d) { return d.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric' }) + ' · ' + d.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' }); };
    var range = function (a, b) { return fmt(a) + '–' + b.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' }); };
    function toast(msg) { var t = document.getElementById('toast'); t.textContent = msg; t.className = 'show'; clearTimeout(window._tt); window._tt = setTimeout(function () { t.className = ''; }, 2400); }

    $('#find').jqxButton({ width: 96, height: 38 }).addClass('jqx-primary');
    $('#resolve').jqxButton({ height: 38 });

    function findSlots() {
        var q = document.getElementById('q').value.trim(); if (!q) { return; }
        document.getElementById('results').innerHTML = '<div class="muted">Looking for open times…</div>';
        $('#scheduler').jqxScheduler('aiFindSlot', q).then(function (r) {
            if (!r.slots.length) { document.getElementById('results').innerHTML = '<div class="muted">No open slots in that window. Try widening the range.</div>'; return; }
            var subj = r.subject || 'Meeting';
            document.getElementById('results').innerHTML = '<div class="rlabel">' + r.slots.length + ' open time' + (r.slots.length > 1 ? 's' : '') + (r.query.resourceId ? ' in ' + r.query.resourceId : '') + ' · ' + r.query.durationMinutes + ' min</div>' +
                r.slots.map(function (s, i) {
                    return '<div class="slot"><span class="slot-when">' + range(new Date(s.from), new Date(s.to)) + '</span>' +
                        '<button class="book" data-i="' + i + '">Book</button></div>';
                }).join('');
            var slots = r.slots;
            Array.prototype.forEach.call(document.querySelectorAll('#results .book'), function (btn) {
                btn.onclick = function () {
                    var s = slots[+btn.getAttribute('data-i')];
                    $('#scheduler').jqxScheduler('aiBookSlot', { from: new Date(s.from), to: new Date(s.to), resourceId: s.resourceId }, { subject: subj });
                    toast('Booked "' + subj + '" · ' + range(new Date(s.from), new Date(s.to)));
                    btn.textContent = 'Booked'; btn.disabled = true; btn.className = 'book booked';
                };
            });
        }, function (err) { document.getElementById('results').innerHTML = '<div class="muted">' + err.message + '</div>'; });
    }
    $('#find').on('click', findSlots);
    $('#q').on('keydown', function (e) { if (e.keyCode === 13) { findSlots(); } });
    Array.prototype.forEach.call(document.querySelectorAll('.chip'), function (c) { c.onclick = function () { document.getElementById('q').value = c.textContent; findSlots(); }; });

    $('#resolve').on('click', function () {
        $('#scheduler').jqxScheduler('aiResolveConflicts').then(function (r) {
            if (!r.proposals.length) { document.getElementById('results').innerHTML = '<div class="muted">No conflicts found. Everything is clear. ✅</div>'; return; }
            document.getElementById('results').innerHTML = '<div class="rlabel">' + r.proposals.length + ' conflict' + (r.proposals.length > 1 ? 's' : '') + ' found</div>' +
                r.proposals.map(function (p) {
                    return '<div class="slot conflict"><span class="slot-when"><b>' + p.subject + '</b> clashes with <b>' + p.conflictsWith + '</b><br><span class="muted">move ' + fmt(new Date(p.currentFrom)) + ' → ' + fmt(new Date(p.proposedFrom)) + '</span></span></div>';
                }).join('') +
                '<div style="margin-top:10px"><button id="applyfix" class="book">Apply ' + r.proposals.length + ' reschedule' + (r.proposals.length > 1 ? 's' : '') + '</button></div>';
            document.getElementById('applyfix').onclick = function () {
                var n = $('#scheduler').jqxScheduler('aiApplyResolution', r.proposals);
                toast('Rescheduled ' + n + ' appointment' + (n > 1 ? 's' : '') + ' to clear conflicts');
                document.getElementById('results').innerHTML = '<div class="muted">Applied — conflicts cleared. ✅</div>';
            };
        });
    });
});

body.html

<div class="wrap">
    <span class="kicker">✦ jqxScheduler AI</span>
    <h1>Smart scheduling</h1>
    <p class="lead">Describe what you need in plain language. The Scheduler reads everyone's real availability, proposes <b>genuinely open</b> times (never an invented one), and books on your confirm. It can also spot double-bookings and reschedule them in one click.</p>

    <div class="bar">
        <div class="box"><input id="q" type="text" placeholder="e.g. 'find 30 min in Room A tomorrow afternoon'"></div>
        <input type="button" id="find" value="Find a time">
        <input type="button" id="resolve" value="Resolve conflicts">
    </div>
    <div class="chips">
        <span class="chip">find 30 min in Room A tomorrow afternoon</span>
        <span class="chip">find 1 hour in Room B this week</span>
        <span class="chip">find 45 minutes before Friday</span>
    </div>

    <div class="grid">
        <div class="card"><div id="scheduler"></div></div>
        <div class="card"><div id="results"><div class="muted">Ask for a time above, or click <b>Resolve conflicts</b> — there's an intentional double-booking today in Room A.</div></div></div>
    </div>
</div>
<div id="toast"></div>

Learn more

More jQuery Scheduler demos