You can certainly appeal this decision, it sounds as if you have nothing to lose. As long as you submit a 'fit note' (sicknote) from your GP, dated to the day after your ESA finishes, you should then get the assessment rate of ESA (as long as you have not already had 365 days in the WRAG on a contributory basis).
Our appeals FAQs include how long you have to appeal, how to submit an appeal etc
Appeals FAQs and our ESA claims guide will be helpful
ESA claims and appeals I suggest that you bookmark this page, or make it a favourite on your web browser, so that you can find it easily in future. this will enable you to return to ask any further questions and we will have the advantage of everything being in one place