Set up your Python dev environment for PHLO

    In this guide, you will learn how to set up a development environment in under 5 minutes to trigger a PHLO.

    Prerequisites

    Install Python and the Plivo Python SDK

    You must set up and install Python and Plivo’s Python SDK to trigger a PHLO. Here’s how.

    Install Python

    Operating SystemInstructions
    OS X & LinuxYou would already have Python installed, you can check this by running the command python --version in the terminal
    WindowsTo install Python on Windows you can follow the instructions from here.

    Install Plivo Python Package

    • Create a project directory, run the following command:

      $ mkdir mypythonapp
      
    • Change the directory to our project directory in the command line:

      $ cd mypythonapp
      
    • Install the SDK using pip

      pip install plivo
      
    • Alternatively, you can download the source code from this 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.

    Trigger a PHLO

    Once you have created and configured your PHLO, copy the PHLO Run URL. You can integrate a PHLO into your application workflow by making an API request to the PHLO URL with the required payload.

    With Static Payload

    You can choose to either configure the mandatory params required for a PHLO while creating the PHLO itself or, you can pass the params as payload while triggering the PHLO from your app.

    Note: When you configure the params while creating the PHLO, the values are hardcoded, and they act as static payload.

    With Static Payload

    Code

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    import plivo
    
    auth_id = 'Your AUTH ID'
    auth_token = 'Your AUTH Token'
    phlo_id = 'Your PHLO ID' # https://console.plivo.com/phlo/list/
    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)
    

    With Dynamic Payload

    To use dynamic values for the parameters, you can use the liquid templating params while creating the PHLO and pass the values while triggering the PHLO.

    With Dynamic Payload

    Code

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    import plivo
    
    auth_id = 'Your AUTH ID'
    auth_token = 'Your AUTH Token'
    phlo_id = 'Your PHLO ID' # https://console.plivo.com/phlo/list/
    payload = {"from" : "+14157778888","to" : "+14157778889"}
    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)
    

    You can get your Auth_ID and Auth_token from your dashboard AUTHID

    You can find the PHLO_ID on the PHLO Listing page. PHLO Listing