You are doing a lot of asynchronous stuff, some of it conditional, and you aren't always waiting for the response. Take a look at the [`async`](https://github.com/caolan/async) library, particularly `async.waterfall` and `async.parallel`, it might help you organize this better.

You should also take advantage of early returning when you can so you don't have large nested conditional blocks.