I did have insomnia and startled waking, sometimes gasping for breath.
Two weeks ago I was prescribed Elavil 10 mg to help apparently with sleep and pain.
So far it helps with sleep but not pain. Doc said to try 20 mg and I only tried one night of the double dose so far, increased dry mouth side effect and insane dreams so I doubt I'll stay on 20mg.
Sorry you're having such a rough time sleeping. It is truly debilitating.