All Collections
Voice
How do I block incoming calls to my number?
How do I block incoming calls to my number?

blocking incoming calls

n
Written by nyakio muriuki
Updated over a week ago

You can send a reject action when someone calls your number.

Below is a sample code on how to go around this:

from flask import Flask, request
app = Flask(__name__)

@app.route("/", methods=["GET", "POST"])
def say():
#check call direction (from the response sent to your callback URL
direction = request.values.get("direction", None)
# send a reject response if the direction is Inbound
response = ''
if (direction == "Inbound"):
response = '<?xml version="1.0"?>'
response += '<Response>'
response += '<Reject/>'
response += '</Response>'
# else do what you want with outbound calls(call logic here) eg: say something, dial a sip line etc.
else:
response = '<?xml version="1.0"?>'
response += '<Response>' response += '<Say> Hello, I will reject your incoming call but will call you back! </Say>'
response += '</Response>'
return response

Did this answer your question?