Skip to main content
Get started with Plivo Voice in minutes. This guide walks you through making your first outbound call and receiving incoming calls.

Prerequisites

Before you begin:
  1. Sign up for a Plivo account (free trial includes credits)
  2. Note your Auth ID and Auth Token from the console dashboard
  3. Rent a phone number for receiving calls

Install the SDK

pip install plivo
For web framework support, also install Flask:
pip install flask

Make an Outbound Call

Create a call from your Plivo number to any phone number. When the call is answered, Plivo fetches XML instructions from your answer_url.
Outbound call flow
import plivo

client = plivo.RestClient('<auth_id>', '<auth_token>')

response = client.calls.create(
    from_='+14151234567',  # Your Plivo number
    to_='+14157654321',    # Destination number
    answer_url='https://s3.amazonaws.com/static.plivo.com/answer.xml',
    answer_method='GET'
)

print(response)
The sample answer.xml file plays a message:
<Response>
    <Speak>Congratulations! You've made your first outbound call!</Speak>
</Response>
Replace this URL with your own server endpoint to control call behavior dynamically.

Receive an Incoming Call

Set up a web server to handle incoming calls. When someone calls your Plivo number, Plivo sends a request to your Answer URL and executes the XML instructions you return.
Inbound call flow
from flask import Flask, Response
from plivo import plivoxml

app = Flask(__name__)

@app.route('/answer/', methods=['GET', 'POST'])
def answer_call():
    response = plivoxml.ResponseElement()
    response.add(plivoxml.SpeakElement('Hello! Thanks for calling.'))
    return Response(response.to_string(), mimetype='application/xml')

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)
Run: python app.py

Expose Your Server

Use ngrok to expose your local server to the internet:
ngrok http 5000
Copy the HTTPS forwarding URL (e.g., https://abc123.ngrok.io).

Configure Your Number

  1. Go to Voice Applications in the Plivo console
  2. Click Add New Application
  3. Set the Answer URL to your ngrok URL + /answer/ (e.g., https://abc123.ngrok.io/answer/)
  4. Save the application
  5. Go to Active Numbers
  6. Select your number and assign your application
Now call your Plivo number to hear the greeting!

Forward a Call

Dial another number when receiving an incoming call.
from flask import Flask, Response
from plivo import plivoxml

app = Flask(__name__)

@app.route('/forward/', methods=['GET', 'POST'])
def forward_call():
    response = plivoxml.ResponseElement()
    dial = plivoxml.DialElement()
    dial.add(plivoxml.NumberElement('+14157654321'))
    response.add(dial)
    return Response(response.to_string(), mimetype='application/xml')

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)

Next Steps

Call API Reference

Complete API documentation for managing calls

XML Reference

All XML elements for call control

Use Cases

Common voice application patterns

Webhooks

Handle call events in real-time

Framework-Specific Guides

For detailed setup with specific frameworks:

Environment Variables

Store credentials securely using environment variables:
export PLIVO_AUTH_ID=your_auth_id
export PLIVO_AUTH_TOKEN=your_auth_token
All Plivo SDKs automatically read these variables when you initialize the client without arguments:
# Python
client = plivo.RestClient()  # Reads from environment
// Node.js
const client = new plivo.Client();  // Reads from environment