I have also sold clothing on London's Oxford Street, worked a construction crew, run an escort service and offended thousands as weekly film critic for a pair of big-city alternative weeklies. Well, the secret is in the doing. If you really want this, you have to, of course, write the book, but more importantly, you have to research the markets, write the query letters, do the follow-up letters, take the rejections on the chin and not give up. Walk into any bookstore or library and you'll see that a lot of people have persevered. It's not so much knowing a secret as having the determination.
Agents are indeed important.
We, as readers, see the books when they hit the libraries and the book stores. They have a finger on the pulse of the industry. I was fortunate to have an agent as I was writing Deviant Ways, and she helped rein me in whenever I went astray. My advice would be to do the research first. Find out which agencies have sold projects similar to what you're working on.