Hello and welcome to Just Answer!
When the battery goes dead or is weak, it will cause the PCM to lose its memory for the idle air control motor. If your battery is weak, I would suggest replacing it and if it is good but just needs to be charged, I would fully charge the battery! After the battery is fully charged you should disconnect the battery for 1 minute, then re-connect and start it up and see if it still does it.
If your truck is still stalling i would have the following done.
Could I get you to purchase a can of air intake/throttle body cleaner?
After you get some, I need you to pull the air cleaner off so you can see the throttle body.
Then start your truck and get it to operating temp and spray the cleaner into the throttle body to clean up your throttle blades and idle air control motor. There is a port at the back of the throttle body between the throttle body bores. I need you to spray a half of a can through that port and the rest through the bores to clean it up. You will need to run the engine as you spray the cleaner through, so spray it in when the vehicle is outside. Someone will have to keep the engine running as you spray the cleaner through because it will want to stall. After you finish spraying the cleaner through run the engine at a fast idle for a couple minutes, then shut the engine off and disconnect the battery for 1 minute and reconnect and start the engine. This should take care of your problem, if not let me know, thanks and good luck!