Adds messages function for retrieving recent messages.