I've seen the Jaquet-Droz automata[1] in Neuchatel on the one day a month they run them. They're demoed by a watchmaker who understands and maintains them.
The three automata are the Musician, the Artist, and the Writer. These were made between 1764 and 1778. The Musician and the Artist are just playing back pre-recorded motions from a set of cams. To increase the length of the recording up, there's a stack of cams, and after one turn, the stack moves vertically to play the next cams. So there are two clockwork trains taking turns - playout, and cam selection. It's a beautiful piece of work, especially when you realize someone made all those cams by hand, with a file.
The Writer, which writes text with a quill, is programmable. There's the stack of cams that move vertically to switch cams, as with the others. But with the Writer, the cam selection is programmable. There's a programming wheel made of little screw-on sections of different heights, and a supply of cam sections which indicate what letter to print next. It's an encoding with at least 26 different levels, probably more. I'm not sure if letter case is encoded on the main cam.
It's all very compact, fitting inside the bodies of the dolls. There's no huge mechanical box hidden away somewhere. Even today it would be tough to make that mechanism work, although there are still watchmaking companies that could do it.
Better video of the Writer.[2] You can see the cam stack and the programming wheel working.