We just call it the telegraph, forgetting that at one time the term referred to other forms of long-distance signaling. But it was a big day when men learned to use electrical impulses to send coded text messages through strung wires (or, later, by radio). The electromagnetic telegraph, which sprang up with the railroad, and became indispensible to it, changed everything. Within a few decades, people were communicating from one end of the continent to the other, and then, via undersea cable, across the North Atlantic. The era of electronic mass communication was on its way.
The system that eventually emerged built upon many inventions, including many that worked but were commercially impractical. Not going into it here, though a brief run through is very interesting. (A Wikipedia search will tell you anything you want to know.) The world’s first commercial telegraph was developed in England, patented in 1837, and put into operation (a 13-mile line) on the Great Western Railway in 1838. Telegraph operations became standard on British railways, then became a form of mass communication there when the instruments were installed in post offices across the country.
In that same year of 1837, in the United States, Samuel F.B. Morse independently developed and patented an electrical telegraph, and devised the Morse Code to communicate letters and numbers as combinations of short and long electrical impulses. He sent the first telegram in the United States on 11 January 1838, across two miles of wire. The message that everyone knows he sent, “What hath God wrought,” came six years later, in a demonstration along a transmission line strung between Washington and Baltimore. (Only 40 miles apart, the two cities in 1844 were connected by poor roads and otherwise accessible to each other only by a circuitous passage by ship.) In America, as in Great Britain, railroads immediately saw the necessity for some means of communication within its system that moved faster than the engines , which themselves moved at speeds never before seen.