60 participants diagnosed with insomnia will be recruited to the study through referrals from health care professionals at Kingston Health Sciences Centre (KHSC), family physicians, and other health care providers or self-referrals. After consenting to participate in the study, an initial psychiatric assessment will be completed by one of the psychiatrists on the study to confirm the diagnosis and eligibility to take part in the study. Inclusion criteria: 18 years old or older; non-organic insomnia (F51.0) (World Health Organization 1995); difficulty initiating \[sleep onset latency (SOL)\] and/or maintaining sleep \[wake after sleep onset (WASO)\] for?=?30 min and/or use of sleep-promoting medication (SPM) at least three nights per week for at least 3 months (Buysse et al. 2006); speak and read English, and consistent and reliable access to the internet.Exclusion criteria includes presence of another untreated sleep disorder such as sleep apnea, alcohol or substance use disorder, ongoing cognitive-behavioral psychotherapy, non-assessed or untreated clinically significant somatic or mental symptoms or illnesses or other sleep disorders that could explain current insomnia symptoms or interfere with or be worsened by CBT-i. Alcohol and substance use will be evaluated during the initial assessment by a psychiatrist on the research team. If the participant meets criteria for a substance use disorder, they will be excluded from the study and directed to the proper resources (i.e., support groups). Pregnant women are excluded from participation owing to concerns about potential adverse fetal effects of treatment as there are no adequate and well controlled studies on trazodone in pregnant women for it to be deemed completely safe for use during pregnancy. During the initial assessment before enrollment, participants will be explained thoroughly and transparently the potential risks and benefits of trazodone in pregnancy and will be asked if they are or think they may be pregnant. Pregnant participants or participants who think that they may be pregnant will be excluded from participation in the trial. This pregnancy testing plan can minimize potential fetal risks and protect women from potential harm while minimizing participants' burdens and maximizing the benefits of participation in the clinical trial for females of reproductive potentials. Additionally, if a participant thinks that they may be pregnant or becomes pregnant during the duration of the study, they will be instructed to meet with the psychiatrist and be removed from eligibility, terminating study participation. Participants will be advised to speak with the doctor and the doctor will help the participant to decide the treatment option to withdraw trazodone that is best for her and her baby. To withdraw trazodone, the dosage of trazodone should be tapered off gradually under a doctor's advice.

Upon completion of the initial assessment which determines eligibility, all eligible participants will then be randomly assigned to two groups using the online randomization ( https://www.graphpad.com/quickcalcs/index.cfm ). Participants assigned to group A will be prescribed trazodone in addition to their treatment as usual (TAU), and participants assigned to group B will receive e-CBTi along with TAU. Patients in the e-CBTi experimental group will receive a 7-week online program in addition to treatment as usual. The content of this program will involve interactive and engaging therapy modules, for which participants will receive individualized feedback from a therapist each week. All online sessions and interactions will occur through a secure online platform (OPTT). Through the platform, the pre-designed therapy modules are assigned to the patients, and are accessible to them at any time through the week. Each module consists of approximately 30 slides, which take an average of 45 minutes to complete. Every week participants will submit homework, which is then directly submitted to the therapist that will provide personalized feedback to each patient. The other group will be prescribed trazodone in addition to their TAU for 7 weeks, which has been scietifically proven to effectively treat insomnia. Participants allocated to this arm will also have the opportunity to take part in the e-CBTi after the 7 weeks study period. Participants in the pharmacotherapy group will be asked to complete the same questionnaire as the e-CBTi group. All sleep diary and ISI information are collected via OPTT regardless of study arms.

Pharmaceutical Intervention Trazodone is the treatment of choice for insomnia and participants allocated to the pharmaceutical intervention group will be prescribed trazodone as regular treatment for the duration of the study. Participants on trazodone will also visit the psychiatrist every month to ensure that the wellbeing of the participants are protected, the quality of the data is maintained, and the conduct of the trial are in compliance with the approved protocol, and other regulatory requirements. Trazodone is the routine practice for insomnia and trazodone is covered for most patients (eg. Ontario works, ODSP, under age 25, etc). If the patient is not covered for trazodone, the research lab will provide gift cards available in the lab to accommodate the $50/month for cost of trazodone.

e-CBTi intervention: Online Module Content The e-CBTi modules will involve guiding participants to develop constructive and balanced strategies that would help assist participants to handle sleep problems that are affecting their life. The Online CBTi is based on a simple but powerful idea that insomnia is caused by thoughts and behaviors that can be changed, thus the module aims to adjust the negative thinking so that they can think about and adapt to the things that are happening to them; which allows participants to adjust the way they behave and think about their problems in a way that is not as negative and instead in a way that is potentially more realistic and productive. The module content is designed to help patients with insomnia to deal with inaccurate thoughts about sleep and negative sleep behaviors effectively, change participants' lifestyle practices that negatively affect their sleep, and improve relaxation skills to improve healthy sleep patterns. More specifically, we focus on addressing and exploring the concept of sleep, sleep habits, sleep hygiene, bedtime worries, negative thoughts, and thoughts examination during our module to assist participants in working on thought processes, challenging irrational thoughts, and replacing them with balanced alternative thinking related to sleep.

All therapists are research assistants hired by the principal investigator. They all undergo training in psychotherapy and additional training from a psychiatrist on the research team before any interaction with participants. During this training, therapists complete feedback on practice homework templates which are reviewed by a psychiatrist on the research team to ensure adequate quality of work. All therapists are supervised by the lead psychiatrist who is an expert in the area of electronically delivered psychotherapy modalities. Before any submission of feedback to a participant, it is reviewed by the lead psychiatrist. Data through out the study would be collected to monitor changes in patients' symptoms through ISI, standard questionnaires and other behavioural variables to assess the efficacy of the treatment. As data is collected through the study, anonymized data (diagnosis, initial, bi-weekly and 7-week assessments) will be openly shared for other researchers to use as well.