Skip to content
CloudVNO

Receive Inbound Calls

Handle inbound phone calls on your CloudVNO numbers using webhooks.

Configure Inbound Webhooks

Set the Voice URL on your number:

number = client.incoming_phone_numbers("+14155551234").update(
    voice_url="https://yourapp.com/inbound-call",
    voice_method="POST"
)

Handle an Inbound Call

@app.route("/inbound-call", methods=["POST"])
def inbound_call():
    from_number = request.form["From"]
    to_number = request.form["To"]

    return Response("""
    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Say>Thank you for calling CloudVNO support. Please hold.</Say>
        <Dial>+14155559999</Dial>
    </Response>
    """, mimetype="text/xml")

Build an IVR Menu

@app.route("/ivr-menu", methods=["POST"])
def ivr_menu():
    return Response("""
    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Gather numDigits="1" action="/ivr-handler" method="POST">
            <Say>Press 1 for Sales. Press 2 for Support. Press 3 for Billing.</Say>
        </Gather>
        <Redirect>/ivr-menu</Redirect>
    </Response>
    """, mimetype="text/xml")

@app.route("/ivr-handler", methods=["POST"])
def ivr_handler():
    digit = request.form.get("Digits")
    routing = {"1": "+14155551111", "2": "+14155552222", "3": "+14155553333"}
    dest = routing.get(digit, "+14155550000")
    return Response(f"""
    <?xml version="1.0" encoding="UTF-8"?>
    <Response><Dial>{dest}</Dial></Response>
    """, mimetype="text/xml")

Webhook Parameters

CloudVNO sends these to your voice webhook on inbound calls:

ParameterDescription
CallSidUnique call identifier
FromCaller's number
ToYour CloudVNO number
CallStatusringing initially
Directioninbound
CallerCityCaller's city (US only)
CallerStateCaller's state (US only)