For all the Sturm und Drang about the toxic culture of Twitter, it seems possible that the leaders of both Iran and the United States turned to the social media site Tuesday to help ensure that a tense night in the Middle East didn’t escalate into all-out war.

After a week when Twitter seemed to bring out the worst impulses of President Donald Trump’s bombast—including an ill-conceived (and potentially illegal) threat over the weekend to bomb Iranian cultural sites—both Trump and Iran’s English-speaking foreign minister tweeted out Tuesday night that neither wished to escalate tit-for-tat attacks into a true war. Their exchange, what Middle East expert Ilan Goldenberg called “real time deescalatory twitter,” came in the hours after Iranian rockets targeted Iraqi bases that housed US and allied personnel, apparent retaliation for the US assassination of Iran’s Quds Force leader, General Qasem Soleimani, in a Baghdad airstrike.

The tweets proved a remarkable modern-day answer to the long-running challenge world leaders have faced in struggling to communicate between nations during unfolding crises—communications necessary both to understand adversaries’ intentions and to telegraph their own.

At the height of the Cuban Missile Crisis, leaders sweated as communications moved slowly—ever so slowly—between Washington and Moscow. It took the US Embassy in Moscow nearly 12 hours to encode one 2,750-word message from the Soviet Union, the equivalent of about five typed pages.

Communicating quickly with world leaders other than Russia has long proved challenging for US leaders.

In turn, whenever the Soviet Embassy in Washington needed to send a message back to Moscow, they relied on a bicycle messenger from the local DC office of Western Union. “After he pedaled away with my urgent cable, we at the embassy could only pray that he would take it to the Western Union office without delay and not stop to chat on the way with some girl,” Ambassador Anatoly Dobrydin recalled years later in his memoirs.

When Soviet leader Nikita Khrushchev finally offered a deal to bring the crisis to a close, he was deeply worried about the speed of unfolding events. Instead of transmitting through normal channels, he had the letter read out loud over Radio Moscow to speed Washington’s receipt.

In the years following the Cuban Missile Crisis, the US and Soviet Union looked for ways to improve their direct links of communication. They ultimately settled on teletype machines, installed in the Pentagon and the Kremlin, that came to be popularly known as the Hotline or “the red phone,” even though there never were, and still aren’t, actual phones involved. In fact, planners at the time realized—in a lesson that still applied Tuesday night with Iran—the importance of writing things down to avoid any mistranslation, garbled messages, or misunderstandings. They understood that speaking precisely in a crisis was key, and—again in a lesson that seems tailor-made for the Trump era—they knew the unpredictability of an unscripted phone call.

Yet even the new Hotline was hardly a direct link. The telegraph circuit bounced from Washington to London to Copenhagen to Stockholm to Helsinki before finally reaching Moscow, while a second backup line ran through Morocco. (The criticality of the backup line has been proven at least three times: once when a Finnish farmer severed the primary cable while plowing his field, once after a Baltimore manhole fire knocked out it out, and a third time when a bulldozer in Denmark cut it during a construction project.) The “MOLINK” communication system, as it’s known in military parlance, was used for the first time during another Middle Eastern crisis, the Arab-Israeli Six-Day War, when President Lyndon Johnson and Soviet Premier Alexei Kosygin exchanged 19 messages, explaining each of their respective actions to ensure that the two superpowers didn’t get drawn into the regional conflict.

In the years since, the Hotline has been ever ready for a crisis, monitored 24 hours a day, and continuously tested every hour, using dummy messages that have included everything from sports scores to Shakespeare quotes. Tradition holds that twice a year, on New Year’s Day and August 30—the Hotline’s birthday—Moscow and Washington exchange formal greetings. In the decades since its creation, the Hotline has been upgraded continuously to rely on satellites, then faxes, and most recently email.