This is the most important question here. I hope OP has been able to address the original cause of the insomnia, lest it happen again.
Once you have insomnia for a few weeks it tends to be self-reinforcing. I didn't get adequate medical care during the first few weeks, when it was acute, so it became chronic. I tried, but the doctor wrote me a half-strength prescription for Ambien, and that was all. It didn't work.
But the thing with insomnia is that it is self-reinforcing. You get conditioned to lying in bed awake, and that's what your brain then expects to do when you go to bed. And then you get anxious about it, which makes it worse. Once you have it, removing the original cause doesn't solve the problem.
In my defense, I worked under these conditions for five years before it became an issue.