The best way is to explain the task to be automated as if you were explaining it to someone who would perform it manually. The better the specification, the faster you will get your results. Find out how to write excellent project specifications, including examples.