The miracle drug for insomnia are dual orexin receptor antagonists due to it's unique mechanism of action and also more favorable side effect profile when compared to traditional sleep aids.
Other drugs for insomnia are Ambien and even melatonin, although melatonin is not considered to be a drug.
Melatonin is naturally produced in the body and not having enough of the melatonin can prevent sleep and so by taking some extra melatonin it can help you sleep better.
The pill that puts you into a deep sleep are Z drug pills like Ambien/Zolpidem, Lunesta/Eszopiclone and even benzodiazepines like Restoril/Temazepam.
Other drugs that help to put you into a deep sleep are dual receptor antagonists like Belsomra/Suvorexant or even antidepressants that are sedating like Doxepin.
Most of these drugs for sleep are intended for short term use as a result of dependency risks and often only improve your sleep duration by 10 minutes to 30 minutes.
Although some people sleep much more soundly with these sleep inducing drugs than others do, so your results can vary.
When you can't sleep, you should ideally get out of bed after 20 to 30 minutes and avoid any screens 1 hour or more before bed and do quiet activities in dim light until you're sleepy.
To get immediate relaxation, try doing some breathing techniques, reading or progressive muscle relaxation.
And keep your bedroom, quiet, dark and cool and hide your clock to avoid anxiety.
If you're still awake after trying to sleep for 15 minutes to 20 minutes, get up and leave your bedroom to prevent associating your bed with anxiety.
And engage in low stimulation activities like journaling, reading or even listening to some quiet music.
Use low lighting to avoid triggering your brain to wake up.
And try doing some deep breathing exercises like the "4-7-8" method, or even visualize a calming scene.
Also try progressive muscle relaxation by tensing and releasing muscle groups from your toes to your forehead to reduce tension.
Consider using some blackout curtains, a sleep mask or even some white noise and keep your phones, tablets, laptops etc away as the blue light hampers sleep.
And avoid caffeine, nicotine and large meals before bed.
You can also try some over the counter melatonin supplements as I've found melatonin supplements taken around 1 hour before bed has helped me fall asleep.