A method (and associated apparatus) of providing electrical neurostimulationtherapy to a patient using an implanted neurostimulator comprises (a)delivering an electrical stimulation to a nerve and (b) determining whether apredetermined condition has occurred as a result of the stimulation. Themethod further comprises (c) if the predetermined condition has not occurred,adjusting one or more stimulation parameters; and (d) repeating (a), (b), and(c) until the predetermined condition occurs.