Improvising is a lot more structured than people think, so it needs 'setting up'.
Firstly, you don't improvise on thin air, you improvise on a chord sequence. It follows that you have to know your chords, and your sequence. The chord sequence could be incredibly simple. A modal pair like a major chord and a minor chord a tone above is a good start. I, IV and V, of course, either bluesy or not.
Then you need a scale, or a part of a scale. Chord tones will always do, and your ear will usually tell you which in-between notes work and which don't. Pentatonic scales are great because they simplify this whole choice process.
Then you need a rhythmic texture (beat). This might easily arise out of your doodling, but it can also be a good seed - start off with your chords and a rhythmic tapping pattern and see what comes up.
Of course, you can borrow all these elements from an existing composition, song or 'standard', as the pros do.
Try Musicarta.com for a systematic approach. But there again, I'm biased - it's my site!!