Depends on what you specify as SPAM. Simple advertising would be considered SPAM by some and prospecting by others. Like phone calls, you could have a button on the agent script that would add the phone number to a table and if that comes through a messaging flow, check that table for the number and disconnect it if successful. You could also use a keyword search for things like just "Hi" or "Remember me?" and disconnect those after popping number into the table. You'll need a data action to insert a row into the data table. Search the community for blocking numbers.