MINUTES after last week’s violent attacks on America’s missions in the Middle East, the country’s embassy in Cairo was already on Twitter. It tweeted an emergency number for American citizens. It criticised Egypt’s Muslim Brotherhood for supporting the protests on their Arabic feed. And it thanked fellow tweeters for their condolences on the murder of the American ambassador to Libya, Christopher Stevens.

Welcome to the new world of e-diplomacy, also called, more pretentiously, “21st-century-statecraft”. Historically, governments left diplomacy to the cagey and the discreet, who mostly met behind closed doors. Now they are also using Twitter, Facebook, YouTube and local social-media services such as China’s microblogging site, Sina Weibo.

Much of this online activity is “public diplomacy”, meaning governments communicating directly with the citizens of another country. But e-diplomacy is an easy and cheap tool for other purposes, too: responding to disasters, gathering information and managing relationships. Some diplomats also use Twitter to communicate among themselves (many don’t read their own e-mail).

Predictably, America is leading the pack. Since Hillary Clinton, the country’s secretary of state, launched her own 21st-century-statecraft programme in 2009, her ministry has spawned 194 Twitter accounts and 200 Facebook pages with millions of “followers” (subscribers). The State Department in effect operates a “global media empire”, in the words of Fergus Hanson, a fellow at the Brookings Institution, a think-tank in Washington, DC, and the author of a study of e-diplomacy.

Most other countries lag far behind. About 20 British ambassadors are now on Twitter (perhaps some were inspired by William Hague, the country’s tweeting foreign minister). Russia’s foreign ministry is said to have more than 40 Twitter accounts. Israel has announced it will make more use of e-diplomacy. Even China, which heavily censors social media at home, is interested in using them as a diplomatic tool abroad.

In many countries it is still individuals who push diplomacy online, often for their own ends rather than for government work. Dilma Rousseff, Brazil’s president, and Carl Bildt, Sweden’s foreign minister, have big followings on Twitter (and a knack for writing punchy messages). In America the most important e-diplomat is President Barack Obama, although he only occasionally writes his own tweets. His audience of nearly 20m followers dwarfs those of Venezuela’s autocratic Hugo Chavez (3.4m) and Russia’s prime minister, Dmitry Medvedev (1.5m).

Not being plugged in has become a disadvantage for governments, argues Mr Hanson. In 2010, after suspicions that crimes in Melbourne against Indian students were racially motivated, the number of university applications from India fell by half, reducing what is a big source of income for Australia (Indians are the second-largest group of foreigners studying in the country). In April this year, when two Chinese students were beaten up, Kevin Rudd, the country’s former prime minister, got on Sina Weibo to promise to investigate the matter. Everyone calmed down.

Some argue that social media improves diplomatic preparedness. The State Department monitors social media in five languages and flags, for instance, influential figures in a country whom envoys ought to befriend. With such information, diplomats should be more able to predict events and react to them. “Would we have been better prepared for the Arab spring if we had discovered the hashtag #tahrir earlier?” asks Tom Fletcher, the British ambassador (and twiplomat) in Lebanon.

Yet e-diplomacy also has its critics. They say that by pushing social media and internet freedom, America has persuaded many abroad that the network is just another Trojan horse for American imperialism. “The internet is far too valuable to become an agent of Washington’s digital diplomats,” argues Evgeny Morozov, a noted blogger. Others say that social media do not reinvent diplomacy, but merely add to it: world leaders and their minions still have to meet face-to-face.

And with so many tweeting Talleyrands there is always the danger of e-diplomatic incidents. In June, reacting to an article critical of Estonia’s economic policy by Paul Krugman, a Nobel prize-winning economist, the country’s president, Toomas Hendrik Ilves, took to Twitter to call him “smug, overbearing and patronising”. Wait for a tweet to start a war.

Correction: A previous version of this article wrongly attributed the assertion that the State Department in effect operates a "global media empire" to Alec Ross, who advises Mrs Clinton on innovation. Apologies.