Using this guide, you can set up a development environment in five minutes to trigger a PHLO.
To get started, install Python, the Flask web framework, and Plivo’s Python SDK.
Linux and macOS users should already have Python installed. Windows users can download and install it. Follow instructions to install Flask.
To install the Plivo Python SDK, first create a project directory using the command mkdir mypythonapp
, then change to the directory and install the SDK using pip:
pip install plivo
Alternatively, you can download the source code from our GitHub repo and run
python setup.py install
We recommend that you use virtualenv to manage and segregate your Python environments, instead of using sudo
with your commands and overwriting dependencies.
Create and configure a PHLO, then integrate the PHLO into your application workflow by making an API request to trigger the PHLO with the required payload.
You can run a PHLO with static payload values by entering specific values in fields like from and to on the PHLO console.
To deliver a dynamic payload instead of a static one, define the payload keys as Liquid templates on the PHLO console and pass the values at runtime.
To trigger a PHLO, create a file — we called ours trigger_phlo.py — and paste into it the code below for either a static or dynamic payload.
1
2
3
4
5
6
7
8
9
10
import plivo
auth_id = '<auth_id>'
auth_token = '<auth_token>'
phlo_id = '<phlo_id>'
payload = {"from" : "<Caller_ID>","to" : "<Destination_Number>"}
phlo_client = plivo.phlo.RestClient(auth_id=auth_id, auth_token=auth_token)
phlo = phlo_client.phlo.get(phlo_id)
response = phlo.run(**payload)
print str(response)
1
2
3
4
5
6
7
8
9
import plivo
auth_id = '<auth_id>'
auth_token = '<auth_token>'
phlo_id = '<phlo_id>'
phlo_client = plivo.phlo.RestClient(auth_id=auth_id, auth_token=auth_token)
phlo = phlo_client.phlo.get(phlo_id)
response = phlo.run()
print str(response)
Save the file and run it.
python trigger_phlo.py