Do this ^^^^^^^^^^^
Get you one of those keyboard trigger devices that I see a lot of people use for drums.
Then get your groove on with your best funk face and get into the moment. Let your whole body become a mass of gyrating funk, punk and rap. Then transfer that feeling to the machine.
As for melody, well what I hear in rap is pretty simple and a lot of it sounds like a lullaby or something a kid would sing.
So whatever your musical skills are, use them to put that down.
A song has to have some kind of focus, an idea, a concept. That is the nut you have to crack.
When you find that, your job is to interpret that idea into musical form. Stay in the moment.
Your OP is so terse, we could go on forever so a little background would help.