I have different methods:
Sometimes I have a lyrics or a catchline and probably a melody with that phrase turns into my mind and from that i'll work the song out.
Or i hope for inspiration and play a few chords I know sound well or fit my mood or the lyrics I wrote.
I always figure out which chords the artist is using and save that infomration in my head. Than, probably after months, that chord progressions comes to me and I'll write a melody to it.
I always try to write the thing as a whole in maximum 3 hours.