Python Quickstart: Say a Message

Let's walk through creating your first application, Hello Monkey. We'll use Python to construct this example, but almost any web development language could be used.

Sample App

Now, open a file called and add the following lines:
from flask import Flask
from twilio.twiml.voice_response import VoiceResponse

app = Flask(__name__)

@app.route("/", methods=['GET', 'POST'])
def hello_monkey():
    """Respond to incoming requests."""
    resp = VoiceResponse()
    resp.say("Hello Monkey")

    return str(resp)

if __name__ == "__main__":

Then run Flask in the terminal:

# If you are using virtualenv, you should run source bin/activate now to
# activate your environment.
$ python
* Running on 

You should be able to open a web browser to http://localhost:5000. If you view the page source code, you should see the following text:

<?xml version="1.0" encoding="UTF-8"?>
    <Say>Hello Monkey</Say>

Great! If Twilio reads this URL when someone calls your Twilio number, the caller will hear "Hello Monkey" played back to them. Now we need to get Twilio to request this URL when calls come in.

Let Twilio find your server

At this point in the tutorial, you will need to find a way to expose your server to the public Internet, so Twilio can find it.

Here are some tutorials that may be able to help you:

For the rest of the tutorial, we will assume your server is available at

Try it out

Copy and paste the URL of your server into the "Voice" URL on the Numbers page of your Twilio Account. This way, Twilio will fetch instructions from that URL when people dial your Twilio number.

Now call your Twilio number! You should hear a voice say "Hello Monkey" in response. When you call, Twilio will fetch your URL, and execute the XML instructions listed above. Then Twilio will hang up, because there are no more instructions.

Next: Greet callers by name »

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.