Nathan Doak converted skipper Alan O'Connor's 79th-minute try as Ulster boosted their United Rugby Championship play-off hopes with a 30-28 win over Scarlets.