Songwriting by definition involves creating a melody. Every writer employs his or her own method and having several methods will greatly increase your chances for success. What are some of these methods? A lot of writers will just sit down with their musical instruments and jam around until they come up with something they like. This works but you are kind of dependant on the luck of the moment, how you feel and how much time you have. Some folks will work with chord progressions, repeating or improvising until something emerges they like. This method can be extremely productive if you know a lot of chords. Again, you are sort of dependant on the moment and your muse. Some writers are able create a melody in their heads and then build the chords around it. Any way you use one thing is certain, the more you do it the easier it will become and the better you will get. One way I have found to work well is to write your lyrics and record them in a conversational voice, or just speak them out loud if you don’t have a recorder. Try to notice the natural melody of the language. We are all familiar with the way our questions tend to end on a higher pitch than the rest of the line. This is a simple example but it points out the natural melody of the language. The English language is not a very melodious language compared to the romance languages, like French or Italian, but it is much more melodious than your Germanic and Slavic languages so you can try this with any lyric line. There is a natural melody in everything we say. American English also incorporates words liberally from the romance languages, so helps to add a little lilt to it when spoken in normal conversation. If you listen carefully to your lyric line you will discover a natural melody in the words. You can enhance this natural melody by emphasizing the normal ups and downs of the lyric line.
Melody writing is a mysterious art but can be developed by continually working on it. Try the different methods, listen and examine other melodies. Try listening to some melodies from tunes by great melody writers, Irving Berlin, Cole Porter, Paul McCartney, Brian Wilson are just a few. Experiment with different intervals and tempos. Try to learn what notes are related to each chord and try to create some melodies from within a chord or a bunch of chords. There are lots of ways to create melodies, try them all and try them often. Good luck and have fun.