The vertical sand painting Brother Dusk is working on very much resembles the Tibetan Buddhist ritual creation of a sand mandala (although done horizontally), including the ridged funnel to dispense the sand called a chak pur. A mandala is a 2 or 3 dimensional map of the cosmos or the celestial palace of a Buddha, and is used as a visualization tool. Sand mandalas are swept away upon completion to represent impermanence, a key principle in Buddhist philosophy.
In the books robots are just an obscure legend. Even the word "robot" is known only to a tiny number of people from some of the oldest planets.
This episode isn't based on anything Asimov wrote, it's just bridging the gap between the events inspired by the first two parts of the first novel, i.e. "The Psychohistorians" and "The Encyclopedists".
However, the very violent Imperial answer to the attack in this episode is similar to the Imperial army behavior in the fifth part of the first book: "The Merchant Princes", in which an old man on the planet Siwenna tells Hober Mallow of the bombing of his planet.