Ambien is a medication that is used to treat insomnia. It can be taken orally or rectally. The oral form is more commonly used. Ambien works by binding to the GABA receptors in the brain. This results in a sedative effect. Ambien is usually taken for a short period of time, such as 2-3 weeks. It is not recommended for long-term use.