Issue
Receiving unwanted inbound voice calls—such as spam, robocalls, or nuisance calls—from specific phone numbers can disrupt your business operations and customer experience. This guide provides actionable steps to help you identify, block, and prevent unwanted calls to your Twilio phone numbers.
Product
Twilio Programmable Voice
Cause
Unwanted inbound calls may originate from:
• Telemarketers, robocallers, or automated systems targeting your number.
• Individuals repeatedly calling your number for non-business purposes.
• Numbers previously associated with other users, resulting in legacy traffic.
• Fraudulent or malicious actors attempting to disrupt your service.
Twilio phone numbers, like any public phone number, are accessible to outside callers. While Twilio monitors and delays re-introduction of numbers to minimize unwanted contacts, some calls may still occur.
Resolution
To troubleshoot and block unwanted inbound calls from specific numbers, follow these steps:
Identify the Source
• Review your Twilio Call Logs in the Console or via the REST API to identify the unwanted caller(s) by their phone number (in E.164 format).
Create a Virtual Block List
• Use Twilio Functions or your application logic to maintain a list of blocked numbers.
• When an incoming call matches a blocked number, respond with the <Reject> TwiML verb to immediately hang up the call.
• Example Function code:
exports.handler = function(context, event, callback) {
let numberBlock = [ "+1212555XXXX", "+1702555XXXX" ]; // Add blocked numbers here
let twiml = new Twilio.twiml.VoiceResponse();
if (numberBlock.indexOf(event.From) !== -1) {
twiml.reject();
} else {
twiml.redirect("https://your-webhook-url.com");
}
callback(null, twiml);
};
• Update the block list as needed to include new unwanted numbers.
Configure Your Phone Number’s Voice Webhook
• Point your Twilio phone number’s Voice Webhook to the Function or application that implements the block list logic.
Alternative: Block All Incoming Calls
• If you wish to block all inbound calls, remove the Voice Webhook URL or configure a TwiML Bin with only the <Reject> verb.
Monitor and Update
• Regularly review call logs for new unwanted numbers and update your block list accordingly.
Additional Information
- For more details on blocking calls, see How Can I Stop Receiving or Block Incoming Phone Calls.
- For sample code and implementation guidance, see Reject Incoming Calls with a Phone Number Block List.
- Stopping Inbound Calls from a Specific Number At the Carrier Level (Before Twilio) may also be possible. To do this you can contact your upstream carrier (the provider that delivers calls to your Twilio number) and request a block on the unwanted number(s). Note: Not all carriers offer this, and Twilio cannot block calls before they reach Twilio’s platform.