Ambien, generically known as Zolpidem Zolpidem Zolpidem , is a prescription compound primarily prescribed to treat insomnia . This quickly-acting hypnotic works by affecting certain substances in the mind to promote rest . It's typically taken just shortly before going to sleep and is not recommended for prolonged use . Patien