first off: be sure to ONLY use MAF/Throttle body cleaner NOT carb cleaner. Carb cleaner can melt certain plastics & has been known to ruin some fine-wire MAF's. CRC MAF & Throttle Body cleaner is non-residue, doesn't stink up your hands.
Ok: to test the "needs cleaning" theory, which I agree 210% with that diagnosis: Remove the rubber intake tube from the MAF ot the TB. You didn't specify V6 or V8, but doesn't matter. on the MAF simply spray a light coat of cleaner & you're done. On the TB, installed on the Truck, spray the cleaner into a lint-free towel (I like the Blue- shop paper towels for this). Use your hand to open the throttle blade as far open as possible, swipe as far in as you can get. top & bottom. Wipe down the front AND back of the Throttle blade as best you can.
Put the tube back on, see if it solved the problem. 95% sure it will. If it DOES cure the problem, then go to the local parts store, get a new TB to manifold(v6) or manifold Elbow (v8) gasket. Take the truck home. Remove the tube again, this time completely remove the TB & elbow if equipped. BE aware some v8's have a coolant passage on the EGR side of the elbow. so you will have to either work with those lines connected or drain some coolant. Clean the TB completely & spray a good dose of the cleaner into the intake as well.
on the '02-'03 v8's & most all the 4.0L I am aware of, there IAC (Idle Air Control) Valve is a round lil can on the side of the TB or right near the TB. Be careful spraying/poking/proding. The plunger inside can get wedged easily at an angle. On the '04-up, the IAC is part of the Drive-By-Wire in the TB.
If cleaning the TB doesn't solve the issue. I'd start looking at transmission fluid levels (you can check it your self easily) & general repair history.
'02-03 trucks have a horrible track record with transmission problems.
Rob