Migrating From Plivo to CarrierX
This article will describe how to migrate from Plivo to CarrierX, what difficulties you can meet, and the ways to solve the issues.
The main steps to start working with CarrierX are to create an account and write applications in FlexML, the CarrierX markup language. You can update your existing Plivo XML applications so that they worked with CarrierX.
Migrating Plivo Account to CarrierX
First, you need to register an account with CarrierX. To do that, fill the form at the Contact Us page. Once the account is created, you will get access to the CarrierX portal and API.
Refer to our Getting Started article for more information on how to start work with CarrierX. There you can learn how to obtain an authentication token, which you will use for API requests, and learn how to send a first request.
You can also read the following quick start guides to learn the basics of work with CarrierX:
Setting Applications URLs
Plivo stores the links to the associated applications in the phone number configuration. In CarrierX, it is possible to set up the applications URLs in two places:
-
In the phone number settings
If you have a phone number associated with several endpoints and want to execute the instructions every time the phone number receives a call on all endpoints, you can set the application URL to the phone number. To do this, go to the portal Configure left-side menu, click Phone Numbers, select the phone number you want to edit with the mouse, and switch to the Application: FlexML tab. Here, enter the application URL and Method. You can also set up the Status Callback URL and the Status Callback Method in the same form.
-
In the endpoint settings
If you prefer to set the applications on the per-endpoint basis, go to the portal Configure left-side menu, click Endpoints, select the endpoint you want to edit with the mouse, and switch to the Application: FlexML tab. Here, enter the application Default URL and Default Method.
You need to set the Default Container in the endpoint settings if you want to use the Record verb and store the recordings in CarrierX storage. In the case you do not set it, you will either need to specify this storage container each time when you use the Record
verb or use the external storage for the recordings, also specifying that storage with the Record
verb arguments.
Migrating Applications That Use Client Library
When posting requests from Plivo, users can use the client library provided by Plivo to form these requests.
Requests to and from CarrierX FlexML endpoints do not require to install any additional libraries and can use the standard requests methods, available in various programming languages (e.g., in Python):
Plivo Python Request Example
import plivo
client = plivo.RestClient('PLIVO_AUTH_ID', 'PLIVO_AUTH_TOKEN')
call = client.calls.create(
from_='+14151234567',
to_='+14157654321',
answer_url='https://example.com/path/to/handler',
answer_method='GET',
)
Corresponding CarrierX Python Syntax
import requests, json
url = 'https://api.carrierx.com/flexml/v1/calls'
headers = {'Content-Type':'application/json'}
payload = {"calling_did":"15017122661", "called_did":"15558675310", "url":"https://example.com/path/to/handler", "method":"POST"}
requests.post(url, auth=('CARRIERX_FLEXML_EP_USER_NAME', 'CARRIERX_FLEXML_EP_PASSWORD'), data=json.dumps(payload), headers=headers)
You are free to store the credentials data as environment variables and not to mention them explicitly in your code.
Migrating Plivo XML Applications to FlexML
Plivo uses Plivo XML, and CarrierX uses FlexML as sets of instructions. You can use these instructions to tell the services what they must do when they receive a call. They both use verbs and nouns as a base for their markup language and have similar syntax. FlexML retains certain compatibility with Plivo XML so that your migration could be easier.
You can use most of the main verbs (as well as the Number
noun), which you normally use in Plivo XML, in CarrierX FlexML. They have similar attributes, and you can either use them in FlexML as is, or adapt them changing some of their values. Some of the attributes though are different or missing in FlexML, so you will need to exclude them from your code or replace them with the corresponding ones. Some of the verbs in FlexML have additional attributes, which you can use to expand the application capabilities.
The main difference in the syntax which Plivo XML and FlexML use is that Plivo XML applications normally use the library that Plivo provides for most programming languages. In its turn, FlexML does not use any additional libraries, and you can simply return plain FlexML to the call.
The following sections list the Plivo XML verbs and nouns that are supported in FlexML and provide the FlexML syntax that corresponds to the Plivo XML code which uses the Plivo libraries.
Dial
The Dial
verb connects the calling party with the dialed party. Refer to the Plivo XML and FlexML documentation sections for more information on Dial
.
In Plivo XML, the Dial
verb requires to nest either the Number
or User
nouns inside it. In CarrierX FlexML, you can use the Dial
verb by itself or nest the Number
noun.
You can use the following Plivo XML Dial
verb attributes without any changes in FlexML:
callerId
callerName
confirmKey
hangupOnStar
method
The action
attribute exist both in FlexML and Plivo XML, but requires fully qualified URL in Plivo XML, while in FlexML you can use both absolute and relative URLs.
The timeLimit
and timeout
attributes are similar both in FlexML and Plivo XML, they only differ in their default values:
- In Plivo XML, the
timeLimit
attribute defaults to14400
seconds (4 hours). In CarrierX FlexML, the default value is0
, meaning that the call time is not limited. - In Plivo XML, the default value for
timeout
is not set. In CarrierX FlexML, the default value is30
.
The confirmSound
attribute also exist both in FlexML and Plivo XML. In Plivo XML, it must contain the link to another set of instructions written also in Plivo XML markup language. In CarrierX FlexML, this attribute can contain an URL to an audio file.
The sipHeaders
attribute is not available in FlexML, but you can set the required SIP headers inside the Number
noun and nest it within the Dial
verb like this:
<Response>
<Dial>
<Number>15162065340?X-CustomHeader1=ABC&X-CustomHeader2=DEF</Number>
</Dial>
</Response>
The dialMusic
attribute in Plivo XML functions similar to ringing
in CarrierX FlexML:
- In Plivo XML, you can set the
dialMusic
attribute to eitherreal
(to play the real ringtone of the called party) or to the fully qualified URL of the music that will be played. - In CarrierX FlexML, you can set the
ringing
attribute totrue
to play the ringing sound, or tomusic
to playback the default music. It is also possible to disable any sound with setting this attribute tofalse
.
All the other attributes present in Plivo XML Dial
are currently unsupported in FlexML.
Code Examples
Below is a Python code sample of the PlivoXML Dial
verb and a corresponding Python syntax of the FlexML Dial
code:
Plivo XML Dial Verb Python Example
from plivo import plivoxml
response = plivoxml.ResponseElement()
response.add(
plivoxml.DialElement(action='https://example.com/path/to/handler', method='POST').add(
plivoxml.NumberElement('15671234567')))
print(response.to_string())
Corresponding FlexML Dial Verb Python Syntax
print('''<Response>
<Dial action="https://example.com/path/to/handler" method="POST">15671234567</Dial>
</Response>''')