A loose battery connection can do that.
The clue is that all was well while the alternator was running at speed but as soon as revs went to idle the flat battery couldn't take the load. For some reason the Alt is producing enough power to run the systems but either there isn't enough surplus to charge the battery or it isn't getting through to the bat. Alternators usually work or don't work so it probably isn't the Alt.
Have you checked the belt?