How to Solve Contextual Goal-Oriented Problems with Offline Datasets?