Inclusion Criteria
* Adults aged 18-80 years.
* Meet DSM-5 criteria for Insomnia Disorder.
* Score ≥15 on the Insomnia Severity Index (ISI).
* Sleep initiation and/or maintenance complaints: ≥30 minutes in duration, occurring ≥3 nights/week, with a duration of ≥3 months.
* Willingness to discontinue use of all sleep-related medications prior to enrollment.
* Completion of a 2-week washout period before starting any study medication.
* Willingness to provide clinician assent for participation.
Exclusion Criteria
Patients will be ineligible if they meet any of the following criteria: self-reported daytime napping (≥1 hour per day on ≥3 days per week); a history of suicidal attempts or current ideation, acute or chronic psychiatric or medical condition not controlled by therapy (according to their primary care physician), or current alcohol or drug misuse; or the diagnoses of (or high risk for) other sleep disorders, including circadian rhythm disorders (phase advance or phase delay syndromes), shift work related sleep disorder ("day sleepers" who work \~11pm to 7am) and those with rotating shiftwork schedules. To determine eligibility, all subjects will be screened using a multitier process including: an online screener; an intake interview; a review of the subjects EMR; and, finally, the receipt of the patient's PCP's assent. The following provides additional listing and details (AD) for the Exclusion Criteria:
General Considerations
* Age \< 18 or \> 80 years old
* Inadequate English language comprehension
* Minimal facility with smartphones, computers, i-Pads, or the internet.
Women's Health Given the potential for teratogenic effects with at least trazodone (FDA Class C), women intending to become pregnant, or who are pregnant, or who are breastfeeding will not be eligible for the study. Women will be asked to confirm the use of birth control using self-report and, if applicable, by providing evidence of contraceptive medication (e.g., prescription or pill pack). We will perform a urine pregnancy test at baseline for female participants who are of reproductive age to confirm eligibility. At study enrollment, participants will be told to alert the study team and stop taking study medications if they become pregnant. Participants will be asked to test for pregnancy in the event of a missed period.
Medical and Psychiatric Considerations
* Acute or unstable psychiatric conditions
* Unstable medical condition, significant medical disorder, or acute illness (as determined by their PCP), within one month prior to the study period.
* Significant liver or kidney problems
* Pheochromocytoma or porphyria (contraindicated for trazodone)
* Epilepsy or Seizure Disorder (contraindicated for trazodone)
* Glaucoma or urinary retention (contraindicated for doxepin)
* Increased ocular pressure (contraindicated for diphenhydramine)
* Diagnosis of alcohol or substance use disorder within 2 years prior to the screening visit
* Inability to refrain from drinking alcohol or substance use for at least 3 consecutive days
Sleep Disorders and Sleep Habits
* Any lifetime history of (diagnosis of) breathing disorders, including COPD and sleep apnea.
* Shift work related sleep disorder (work \~11pm to 7am and "day sleeper") and rotating shiftwork schedules
* Circadian rhythm disorders (phase advance or phase delay syndromes)
* Self-reported usual daytime napping ≥1 hour per day (3 or more days per week)
Medications and Concomitant meds
* Known hypersensitivity or contraindication to study drugs
* Known hypersensitivity or contraindication to drugs of the same class as the study treatments
* Known hypersensitivity or contraindication to any excipients of the study drug formulation
* Treatment with CNS active drugs prohibited by the protocol for five half-lives of the respective drug (or 2 weeks)
Lifestyle
* Heavy tobacco use (≥1 pack of cigarettes a day or inability to refrain from smoking during the night)
* Not able or willing to stop treatment with moderate or strong cytochrome P450 3A4 (CYP3A4) inhibitors