There are several different possible causes for this problem. Because of this, the way I would deal with the situation is to address the most likely causes first; and then address the remaining possibilities if the problem continues. Or, to deal with this in the shortest time with the least complication; just do everything listed here in one session.
I would first replace the fuel filter and the camshaft position sensor.
Next, I would thoroughly clean the mass airflow sensor, the throttle body, and the idle air control valve.
Then, I would replace the spark plugs and plug wires. I recommend either NGK # 7164 (TR55IX) or ACDelco Rapidfire # 14 spark plugs. The preferred plug wires are spirally wound metal core magnetic suppression type wire; either Powermax # 700431, or Bosch # 09700, or Borg Warner # CH8638.