The MeetOne appointment picker is a lightweight iframe widget that lets visitors browse and select an available appointment slot directly on your website.
Prerequisites
- A MeetOne tenant domain (for example
acme.meetone.io) with the appointment picker enabled — contact MeetOne support (support@meetone.io) if you're not sure whether it's available for your account. - The ability to add HTML and JavaScript to your website.
Add the Iframe and Basic Styles
1. Add the following styles to your HTML document.
<style>
/* Recommended height for screens up to 575px */
.meetone-appointment-picker iframe {
display: block;
height: 557px;
max-width: 576px;
margin: 0 auto;
}
/* Recommended height for screens from 576px */
@media (min-width: 576px) {
.meetone-appointment-picker iframe {
height: 361px;
}
}
</style>
The initial height above is only a sensible default. Use the meetone.appointment-picker-ready and meetone.appointment-picker-resize messages (below) to set the iframe's actual height once the widget reports it.
2. Add the iframe to your HTML document.
<div class="meetone-appointment-picker">
<iframe
src="https://acme.meetone.io/static_pages/appointment-picker"
width="100%">
</iframe>
</div>
Listen to Events
The picker runs on your MeetOne tenant domain, a different origin than your website, so it can't fire events on your page directly. Instead it sends each event to your page with postMessage. Listen for message events on window and read the event from event.data, where type is the event name. Always check event.origin against your tenant domain before using a message.
meetone.appointment-picker-ready
Sent when the picker has loaded and is ready to use. Carries the picker's current width and height.
window.addEventListener("message", (event) => {
if (event.origin !== "https://acme.meetone.io") return;
if (event.data?.type !== "meetone.appointment-picker-ready") return;
console.log(event.data); // {type, width, height}
});
meetone.appointment-picker-resize
Sent when the picker's dimensions change. Carries the picker's current width and height.
window.addEventListener("message", (event) => {
if (event.origin !== "https://acme.meetone.io") return;
if (event.data?.type !== "meetone.appointment-picker-resize") return;
console.log(event.data); // {type, width, height}
});
meetone.appointment-picker-select
Sent when the user selects a time slot. Carries the selected date and time.
window.addEventListener("message", (event) => {
if (event.origin !== "https://acme.meetone.io") return;
if (event.data?.type !== "meetone.appointment-picker-select") return;
console.log(event.data); // {type, date, time}
});
meetone.appointment-picker-deselect
Sent when the user deselects a time slot or picks another date, so that no slot is currently selected.
window.addEventListener("message", (event) => {
if (event.origin !== "https://acme.meetone.io") return;
if (event.data?.type !== "meetone.appointment-picker-deselect") return;
// No slot is selected
});
Practical Example
Once the picker is loaded, assign its actual height to the iframe. The width is left responsive (no fixed value), and a disabled "Submit" button is enabled only once the visitor selects a time slot:
<div class="meetone-appointment-picker">
<iframe
src="https://acme.meetone.io/static_pages/appointment-picker"
width="100%">
</iframe>
<button disabled>Submit</button>
</div>
<script>
const iframe = document.querySelector(".meetone-appointment-picker iframe");
const button = document.querySelector(".meetone-appointment-picker button");
window.addEventListener("message", (event) => {
if (event.origin !== "https://acme.meetone.io") return;
const data = event.data;
if (!data) return;
switch (data.type) {
// Set the correct height when the picker is ready, and again whenever it resizes
case "meetone.appointment-picker-ready":
case "meetone.appointment-picker-resize":
iframe.style.height = `${data.height}px`;
break;
// Enable the submit button and log the selection
case "meetone.appointment-picker-select":
button.removeAttribute("disabled");
console.log(`${data.date}, ${data.time}`);
break;
// Disable the submit button again on deselection
case "meetone.appointment-picker-deselect":
button.setAttribute("disabled", true);
console.log("No time selected");
break;
}
});
</script>
Security Considerations
If your website uses a Content Security Policy (CSP), allow iframes from your MeetOne tenant domain:
<meta http-equiv="Content-Security-Policy"
content="frame-src https://acme.meetone.io;">
Always serve both your page and the iframe over HTTPS.
Related
Questions? Contact us at support@meetone.io.