You can set up an automation rule under Admin > Workflows > Automations > Ticket creation > New rule:
Conditions:
In tickets > If Subject or Description > contains > sample text
Action:
Set status as 'Closed' or 'Mark as Spam' or 'Delete the ticket' (based on your requirement)