Messages from people you have not talked to yet arrive as conversation requests, which you can approve or decline.
Under Conversation permissions, choose who can send requests: everyone, accounts older than 30 days, accounts with a minimum amount of empathy, or nobody. The allow list keeps people who can reach you at any time.
You can also turn off your online status.