Melatonin works by binding to receptors in the brain that are involved in regulating sleep. When melatonin binds to these receptors, it causes drowsiness and induces sleep. In dogs, melatonin can be used to treat insomnia or jet lag. It can also be used to help reduce anxiety levels during events like thunderstorms or fireworks displays.