Enquiry form callbacks
The callbacks MedosEnquiry fires — onSuccess with the submitted enquiry, onError, and onClose — and the EnquirySubmission payload type.
Pass these to init() or open().
onSuccess
onSuccess?: (enquiry: EnquirySubmission) => voidFires with the submitted payload once the enquiry is filed. In modal mode the
widget then closes itself after 3 seconds, which fires onClose exactly as a
manual dismissal would.
MedosEnquiry.init({
apiKey: "mk_...",
onSuccess: () => {
window.dataLayer?.push({ event: "medos_enquiry_submitted" });
},
});Unlike the booking widget's onSuccess, this one fires with what the patient
typed rather than with a server-assigned id.
That payload is personal data
Name, email, and phone all reach your handler. Don't forward it to analytics — push an event without the fields, as above. See the PII note in Analytics recipes.
onError
onError?: (error: Error) => voidFires when the client fails to start or when a submission is rejected —
a wider net than the booking widget's onError, which only covers startup.
onClose
onClose?: () => voidFires when the modal closes, including the automatic close 3 seconds after a successful submission. Modal mode only.
EnquirySubmission payload
interface EnquirySubmission {
patientName: string;
patientEmail: string;
countryCode: string;
patientPhone: string;
inquirySubject: string;
inquiryMessage: string;
preferredContactMethod: "PHONE" | "EMAIL" | "BOTH";
}A filed enquiry reaches onSuccess looking like this:
{
"patientName": "Asha Menon",
"patientEmail": "asha@example.com",
"countryCode": "+91",
"patientPhone": "9876543210",
"inquirySubject": "Second opinion on a scan",
"inquiryMessage": "I have an MRI from last month and would like a review.",
"preferredContactMethod": "BOTH"
}Configure the enquiry form
Every MedosEnquiry option with its type and default, the init, open and close methods, and the MedosEnquiryConfig TypeScript type.
Enquiry form errors
How MedosEnquiry reports failures — config mistakes that throw, start-up and submission failures that reach onError, and inline field validation.