Plivo Endpoint - Use SIP phones with Plivo

Overview

Plivo Endpoint extends the capabilities of your existing SIP phones, allowing you to add custom business logic when calls are made or received. Traditionally, SIP phones have had very basic functionality and would require to be connected to a PBX, to bring it to life. With Plivo Endpoints you are no longer required to setup and manage a phone system. Any Plivo application can implement the needed business logic to control the SIP phone. And best of all, this business logic can be written using any of your favorite web languages without any need to understand the details of telecom. Plivo supports all popular SIP based soft phones and hardware phones like Bria, Cisco, Polycom etc. Below are some interesting examples to add on to your existing SIP phones:

  1. Instant Conferencing - Calls made through a SIP phone registered with the Plivo can directly be added to a conference bridge.
  2. Access Control - With a few lines of code one can add the ability to restrict calls made from SIP phones or limit the phone to only receive calls.
  3. Monitoring and Reporting - Monitor and report all calls made or received using a SIP phone. One can even create custom dashboards to analyze the data collected using the APIs.
  4. Smart Routing - Add intelligent extensions and shortcuts which route calls to/from traditional phone networks and WebRTC enabled phones.

How It Works

Once your SIP phone is configured and setup your device will establish a connection with Plivo by registering to it. When you initiate a call using the SIP Phone, you’re not connecting to another phone or extension directly. Rather, you’re instructing Plivo to fetch the XML from the attached application on your server to handle the call request. This is similar to the way Plivo handles incoming calls from a regular phone number. All Plivo XML elements are available for use, to handle the call request. You can also use the <Dial> element to dial to a regular phone, WebRTC device or any other SIP phone.

Getting Started

  1. Sign up for a Plivo Account.

  2. Create an Endpoint by visiting this link. Click on ‘New Endpoint’ and fill in the required details.

  3. Make a note of the username Plivo assigns you. Plivo will add random numbers in front of your username. Your username will appear to be yodaXXXXXX. For the purpose of this tutorial, Username - yodaXXXXXX, Password - obiwan, Alias - obiwan

Configure your SIP Phone

  1. Download and install a softphone. If you are on Mac or Windows, download X-lite. On Linux you should download Blink. For this tutorial we will use the X-Lite Softphone.

  2. Launch X-Lite and navigate to preferences. Click on the Accounts tab and hit the ‘+’ icon to add an account.

    X-lite preference

  3. Add the credentials of the endpoint you created during the final step from “Getting Started” - User ID - yodaXXXXXX, Password - obiwan, Domain - phone.plivo.com , Display Name - Yoda Authorization Name - yodaXXXXXX (same as your username)

    Note: Field names may vary based on make and model of the SIP phone. All the configuration will remain in each case.

    X-lite account

  4. Click on OK when you’re done.

  5. Your endpoint entry in the list would be shown as Enabled. This indicates that your SIP phone has successfully registered with Plivo.

Using a Default Dialer App

  1. To start making call, attach the default direct dial app to the endpoint you just created now.

  2. If you have already created the endpoint - go to the endpoints tab and click on the endpoint username. This will open an endpoint edit window. Select the direct_dial app from the “Plivo App” dropdown list.

    SIP Endpoint

  3. If you creating a new endpoint - select the direct_dial app from the “Plivo App” dropdown list.

Next steps: Customizing the Endpoint App

When a call is made from the softphone, Plivo will send a request to the ‘Answer URL’ of the application attached to the endpoint with the parameters related to the call. Plivo expects a valid XML response from the Answer URL in order to proceed with the call. Lets assume in our case, we want to create a simple dial application and make an outbound call to the number entered from the softphone. The Answer URL will receive a request with the ‘From’ and ‘To’ parameter. We need to parse these parameters and return a Dial XML with the appropriate attributes.

<Response> 
    <Dial callerId="18004321321">
        <Number>18001231234</Number> 
    </Dial> 
</Response>

When the above XML is returned on the request, Plivo will make an outbound call to 18001231234 and connect it with the softphone.

Examples

We have examples of direct dial app written in multiple languages. Check out the code on Github and customize it based on your needs.