The telegraph was invented in 1844 by Samuel Morse (1791-1872). It helped long distance communication. It worked by transmmiting electrical signals over a wire between two stations. Also, he invented a code that was made with dots and dashes. Each letter had a dot or a dash to know which letter was the other person trying to say. It was later removed by the telephone.
Samuel Morse was an American guy that after having established his reputation as a portrait painter, in his middle age Morse contributed to the invention of a single-wire telegraph.
https://www.youtube.com/watch?v=wGs57VQHt7M – This is a video of how the telegraph works.