I am attempting to write a song with singing in it for the first time. Now, I have a melody for how I want to sing the lyrics in my head, but I can't figure out how to tell what tones I am singing, so I am unsure what to play on the guitar to keep it in key. Does anybody have any tips on how to know what key you are singing in? Or how to recognize notes when you sing them? Also, when you guys write just an acoustic number with singing and chords, how do you usually go about it? Do you come up with a melody first and then add the chords that match it? Or do you come up with a progression and then figure out the melody later? Thanks in advance...
Well, for writing songs, I usually come up with music first and use the key I'm working in to play a melody on the guitar- this usually evolves into a vocal line, and I'll try this for each section in the song I'm working on. Sometimes it helps to sit down at a piano too- I'm not a piano player by any means, but I find writing and singing to come more easily with piano.

As for the knowing what key you're singing in, I have perfect pitch myself so I don't have much advice other than becoming familiar with qualities of certain keys. Play progressions or scales in certain keys and see how they fit with what you sing. Some keys may strike you as having a certain melodic quality you can identify.
A simple way is to write out your chords on PowerTab or Guitar Pro and then find the notes from the key you're in and that way you can see if the notes clash etc.
Sing to a tuner, that'll show you which notes are you singing.
For long you live and high you fly
But only if you ride the tide
And balanced on the biggest wave
You race toward an early grave.

Ben Hamelech