I am not 100% sure about ambien but after my c/s I was given 10mg one night and they knew i was BF. I had a horrible experience on it though and I will never take it again. Benadryl is okay w/ BF. Have you tried that?
However, I take Xanax on a somewhat regular basis. I see a psychiatrist who specializes in pregnant and postpartum women. She knows I EBF and prescribes Xanax. I have OCD and panic disorder. I usually take 25mcg about 3-5x a week. She said the amount that gets in BM is so minuscule on that dose. It isn't something you should take a ton of all the time, but it is okay occasionally w/ BF. The half life of Xanax is really short so that helps also.