the air conditioner works sporadically. sometimes working and other times not.
You need to take it in for service. Preferably an AC specialist. This is not a DIY job!
It may have a Freon leak and/or be low on Freon.
Definitely take it to a shop,
That’s an indication of a malfunctioning expansion valve.