repo: https://github.com/signalwire/guides/tree/main/Voice/Screen%20Calls%20Based%20on%20Block%20List%20with%20Python - language:python - sdk:compatibility - product:voice This guide implements a call screening system based on the concept of a blocklist containing offending numbers. When a call comes in, the From number will be cross-checked with the block list to see if it is one of the blocked numbers. If so, the call will hang up. If the number is not in the block list, the call flow moves on to the next segment. In this case, I have redirected to an XML Bin. However, depending on your needs, this can point at an XML bin, another webhook, or another part of the code within the same document. As you can see below, it is very simple to implement such a call flow with SignalWire and SignalWire Compatibility XML. What do I need to run this code? -- Check out the code on Github [here](https://github.com/signalwire/guides/tree/main/Voice/Screen%20Calls%20Based%20on%20Block%20List%20with%20Python)! You will need the [Python SDK](/compatibility-api/sdks) and [Flask](https://pypi.org/project/Flask/) framework to run this code. You will need a SignalWire phone number as well as your API Credentials (**API Token**, **Space URL**, and **Project ID**) which can all be found in an easily copyable format within the **API** tab of your SignalWire portal. Running the application -- To install prerequisites, run pip install -r requirements.txt. Using a virtualenv is recommended. To run the application, execute export FLASK_APP=python_call_screening.py then run flask run. You may need to use an SSH tunnel for testing this code – we recommend [ngrok](https://ngrok.com/). After starting the tunnel, you can use the URL you receive from ngrok in your webhook configuration for your phone number. Step by step code walkthrough -- This Github repo has three files: - README.md - Python_call_screening.py - requirements.txt We can skip the README.md file and save the requirements.txt file for when we are running the app. We will discuss python_call_screening.py below. We start with the necessary imports and instantiate a Flask app: python from flask import Flask, request from signalwire.voice_response import VoiceResponse import os app = Flask(__name__) We then define a quick method to fetch the blocked list (this could be a database query or something more involved in a production app): python def get_blocklist(): # there is a default here you can change if you dont want to use the environment variable return os.getenv(BLOCKLIST, +1555778899).split(,) To set the block list, you can set the BLOCKLIST environment variable to a value of a comma-separated list of numbers. For example: bash export BLOCKLIST=+15554433222,+15559988777 If you prefer not to use environment variables, you can set an additional number or demo URL as displayed in the code below with the number +15557778899 or the redirect path