Andy Kropa / AP

Taking a page, perhaps, from Jamie Foxx and T-Pain, Roseanne Barr blamed it on the a-a-a-a-Ambien.

On Tuesday, the controversial TV star tweeted, regarding the Obama aide Valerie Jarrett, an African American woman, that “muslim brotherhood & planet of the apes had a baby=vj.” (The tweet was soon deleted.)

When her show was canceled as a result, Barr attributed the remark to the sedative sleep drug Ambien.

“Guys I did something unforgiveable so do not defend me. It was 2 in the morning and I was ambien tweeting—it was memorial day too—i went 2 far & do not want it defended—it was egregious Indefensible. I made a mistake I wish I hadn’t but...don’t defend it please,” she wrote later on Twitter. She added, “Not giving excuses for what I did (tweeted) but I’ve done weird stuff while on ambien—cracked eggs on the wall at 2am etc.”

Could the sleep medication have prompted Barr to tweet racist sentiments? “It seems unlikely that Ambien is the full culprit here,” said Els van der Helm, the founder of the sleep consultancy Shleep, via email. “Although it can make you act more impulsive/disinhibited.”

People on Ambien have been known to sleep-walk or even sleep-eat. (“We’ve had people eat buttered cigarettes,” Mark Mahowald, of the Minnesota Regional Sleep Disorders Center, told News.com.au. “We’ve had people make salt sandwiches.”) There’s an entire sub-Reddit devoted to Ambien and the wacky texts and emails people sometimes write while on it. One guy even claims to have unconsciously built a cabinet in the middle of the night. Rarely, van der Helm says, people might experience mood changes or aggression.

Indeed, the medication guide for Ambien lists rare side effects like “getting out of bed while not being fully awake and do[ing] an activity that you do not know you are doing” and “abnormal thoughts and behavior ... more outgoing or aggressive behavior than normal, confusion, agitation, hallucinations, worsening of depression, and suicidal thoughts or actions.”

“Basically part of the brain is asleep, while other parts are still active, explaining why your memory might fail you, or why you have lost normal inhibition,” van der Helm told me.

However, she added, “I’m not aware of examples where someone is tweeting certain views (in this case racist views). And I’m also not aware of research showing that such views could be expressed when in (the waking) reality they don’t have any such beliefs or thoughts.”

It’s worth noting the examples of Ambien-induced texts posted online tend to be less coherent than Barr’s. Most of the Ambien messages are full of spelling errors, missed spaces, and instances of “because” spelled “bevayse.” They don’t make a lot of sense. Barr’s text, meanwhile, did—it’s just that its meaning was vile.

David Juurlink, of the Sunnybrook Health Sciences Center, was similarly skeptical that Ambien could produce hateful thoughts. “Drugs like Ambien can absolutely influence one’s actions,” he said. “But in this instance, I think there’s a distinction to be drawn between the decision to tweet something and the content of the tweet. Ambien could certainly prompt an ill-advised tweet, but it wouldn’t explain bigoted or racist content.”

In other words, Ambien might make you tweet with abandon, but it probably won’t make you think racist things if you didn’t already. Sanofi, Ambien’s manufacturer, tweeted as much earlier today:

Even if Barr had not aired her views online, the argument could be made that she should not have had a sitcom in the first place if she does in fact harbor such animosity toward people of color. But in general, the incident is also a reminder of how easy it is, these days, to slip between private thoughts and public snafus. Now that we have so many ways to communicate with the outside world, and so many drugs that alter our behaviors, it’s worth considering whether more internet companies should offer sobriety checks before allowing users to broadcast their unfiltered thoughts.

Van der Helm said it’s recommended that people not take Ambien until they’re actually ready for bed. Or better yet, don’t take it at all. Other therapies are safer and more effective for sleep.

Rachel Salas, an associate professor of neurology at Johns Hopkins Medicine, suggests people “put a passcode on your phone to make it more difficult to send texts, tweets, or make purchases.” But if you can start a car on Ambien, as Jack Nicholson reportedly did once, you can likely unlock your phone.

Perhaps we need something like Google’s erstwhile goggles feature—meant to prevent drunk emailing—but for Twitter.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.