The first reference to a vending machine is in the work of Hero of Alexandria, a first-century engineer and mathematician. His machine accepted a coin and then dispensed holy water. When the coin was deposited, it fell upon a pan attached to a lever. The lever opened a valve which let some water flow out. The pan continued to tilt with the weight of the coin until it fell off, at which point a counterweight snapped the lever up and turned off the valve.
1952 Source Minnesota Historical Society via Wikipedia
Vending machines waited for the Industrial Age before coming to prominence. The first modern coin-operated vending machines were introduced in London, England in the early 1880s, dispensing post cards. The first vending machine in the U.S. was built in 1888 by the Thomas Adams Gum Company, selling gum on New York City train platforms. The idea of adding games to these machines as a further incentive to buy came in 1897 when the Pulver Manufacturing Company added small figures, which would move around whenever somebody bought some gum from their machines. This idea spawned a whole new type of mechanical device known as the “trade stimulators”. The birth of slot machines and pinball is ultimately rooted in these early devices.
Live bait Vending Machine (Wikipedia)
In December 1970, Ussery Industries of Dallas, Texas at its Dallas convention displayed its “talking” vending machine, the Venda Talker. With insertion of a coin, the machine said “thank you” and added a one-liner voiced by comic Henny Youngman.