This sort of technology and innovation has always struck me as way ahead of its time for the ancient world. It most certainly represents some of the most complex feats of engineering in an age before the application of electricity. I'll do a quick rundown of what I know about the West, China, and Islamic world, but if people have other examples (especially from other civilizations like Hindu India), please do share!
Please enjoy.
=WESTERN WORLD=
In Greek mythology, certain deities such as Daedalus and Hephaestus are linked with the creation of automatons. Yet from myth much can be gleaned about what the ancient Greeks were actually capable of. Fortunately, there is pretty clear textual evidence for automatons used at least for entertainment in the ancient Mediterranean. There's also some evidence that the concept was applied to practical situations, such as the washstand and soap-dispenser of Philo of Byzantium (3rd century BC) or the self-adjusting barbershop mirror of his contemporary Ctesibius (3rd century BC) that employed rods and a counterweight. He also was responsible for erecting a cam-operated statue of a deity that was able to sit up and down automatically. Philo was said to have constructed an automaton female maid that poured wine from a jug held in the right hand when one placed a cup into its left hand.
The Greek inventor Heron of Alexandria (1st century AD) in Roman Egypt created and showcased to a large audience his mechanical theater that featured figures in motion for roughly ten minutes. He achieved this mostly with simple rope pulleys and a cogwheel. With many intricate moving parts, he ensured that a drum was sounded by dropping balls with mechanically-timed precision to represent the clashing of thunder in his automatic miniature play.
After the Greco-Roman era, the early Renaissance provided ample grounds for experimentation with automatic moving figurines, such as the self-moving automatons and armor-encased robot of the prolific inventor Leonardo da Vinci (15th century). The motions and actions of such figures became quite complex, such as the head-nodding eye-rolling chest-striking Christian monk of Juanelo Turriano (16th century). The "jack" figurines used in striking clocks from the 14th century onwards in Europe can also be seen as a major part of this tradition. Early examples might be found in the sketchbook work of Villard de Honnecourt (13th century), who drew animal figurines that would repeatedly face the sun. He also made sketches for an automatic sawmill but whether he was the inventor of such works or just simply an astute observer isn't very clear.
The use of automata at European courts became quite numerous by the 17th and 18th centuries, but I shall not list all the examples here since they don't belong to the "ancient" world.
=EAST ASIA=
The Han-dynasty Chinese inventor Zhang Heng (1st century AD) mentioned artificial figures used in plays and it is said that the first Qin emperor (3rd century BC) had a miniature orchestra of musicians blowing onto mouth organs and powered by pulling ropes.
However, the first clear evidence for a mechanically-operated puppet theater in China is seen at the Wei court of Emperor Ming. His engineer Ma Jun (3rd century AD) created an intricate scene of singers, musicians, dancers, acrobats, laborers, and government officials all moving in unison and hydraulically-powered by a waterwheel placed behind the stage.
After Ma's theater such descriptions for mechanical puppets in China become abundant. In the subsequent Sui and Tang Dynasty the use of mechanical puppets were popular at court when it came to consuming alcohol. Huang Gun (7th century) created miniature automatic-traveling boats running along a circuit with little puppets onboard that poured wine into real chalices for dinner guests. In the 8th century a Tang engineer created an artificial mountain with a hydraulic pump and siphon to allow the flow of wine. If the pourer was too slow to drink and fill his cup again, an angry puppet sprang forth from a house on the top of the mountain holding a bat to taunt the slow drinker.
Like medieval European clockworks, the Song-dynasty horologist Su Song (11th century) employed "jack" figurines dressed in silk clothes to spring forth from automatic-opening doors and bang drums and gongs to announce the time from atop his escapement-powered astronomical clock tower. In Korea similar figurines were seen on intricate water clocks such as the "Borugak Jagyeongnu" of Jang Yeong-sil (15th century).
In Japan, mechanical puppets (Karakuri ningyō) used in miniature theater performances were popular from the 17th to 19th centuries during the Tokugawa period.
=ISLAMIC WORLD=
Automatons were also utilized in the medieval Islamic world. Jabir ibn Hayyan (8th century) mentions the use of artificial animals and people that could be controlled by their inventors. The Persian brothers Ahmad, Muhammad and Hasan bin Musa ibn Shakir (9th century) created many different automatons, including automatic-running fountains, one even operated by wind power. They also created a flute player automaton operated by the use of steam. There are lots of interesting detailed sketches from their book available online, such as a self-trimming lamp.
Arguably the most well-known inventor of various automata in the Islamic world was Al-Jazari (13th century). His "elephant clock" had a human figure striking a cymbal to announce the time as well as a metal bird that made a chirping noise. His "castle clock" had similar figurines who appeared from automatic-opening doorways to announce the time every hour. Much like the Chinese example mentioned above, he also created an automatically-moving boat with little musician figurines that played percussion instruments. He fashioned a female humanoid automaton that appeared at timed intervals from an automatic-opening door to pour drinks for guests. He made another female automaton who filled a wash basin every time the water was flushed out by a lever.