I have a Twilio number that can receive SMS messages. Unlike calls, it isn't possible to reject an SMS and accordingly, I get charged even if I don't want the message. Let's say someone bombs my account with spam messages. I want to be able to detect this and disable receiving SMS messages for my Twilio number with the REST API. I know I can login to Twilio and disable messages but I want to be able to do it programmatically. How can this be accomplished in Rails.
2
votes
1 Answers
4
votes
Twilio developer evangelist here.
You can disable receiving SMS messages on your Twilio number by removing the webhook URL from the number. You can do this via the REST API, using the incoming phone numbers resource. Use the API to update the number and remove the URL.
@client = Twilio::REST::Client.new account_sid, auth_token
# Get an object from its sid. If you do not have a sid,
# check out the list resource examples on this page
@number = @client.account.incoming_phone_numbers.get("PHONE_NUMBER_SID")
@number.update(:sms_url => "")
Let me know if that helps at all.