WidgetsEnquiry form

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) => void

Fires 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) => void

Fires 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?: () => void

Fires 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"
}

On this page