Most smartphones these days have number blocking capabilities built into their software. It can also be a feature that is enabled by your phone provider.
That said, there are several call/text blocking apps on Google Play that you can check out if this feature isn't natively available on your phone. It would be helpful by the way to know what phone make and model you have.
For texts it may be a part of your sms app. I know that Yaata can do this. There are apps to block incoming phone calls, like Drupe, but I just created a "Do Not Answer" contact that sends these calls right to voicemail and add numbers I want to block to that contact. The robo-callers detect voicemail and don't bother to leave a message.