How to?

Making parallel calls to two numbers

Step 1. Prerequisites

  1. Register at apifonica.com and create an Apifonica account, if you have not done so already.
  2. Rent an Apifonica local or virtual phone number to be used for calling.
  3. You can find instructions on registering Apifonica accounts and renting numbers here.

Step 2. Creating files and applications

  1. Create a simple XML file and upload the created XML to your server.

    The XML file to be used for parallel calls should look as follows:

    <?xml version="1.0" encoding="UTF-8"?>
     <response>
       <makeCall>
         <number>883xxxxxxxxxxx1</number>
         <number>883xxxxxxxxxxx2</number>
       </makeCall>
     </response>

    where 883xxxxxxxxxxx1 and 883xxxxxxxxxxx2 are numbers you are calling in parallel.

  2. Create an application and associate the XML file you have created with it.

    Detailed instructions on creating XML files and applications can be found here.

Step 3. Making the call

  1. Making the parallel call using console (Make voice call):

    • make the POST request to /accounts/{accountSID}/calls
    • “from“ parameter is a number rented from Apifonica
    • “to“ parameter is a number which receives the call (point 1)
    • “Call_app_sid” parameter is Application SID of created application in which a link to XML is set up (point 2)
  2. Making the parallel call using personal account:

    • Go to Sandbox
    • Choose accountSID in the list of your accounts/subaccounts
    • Choose “from“ parameter in the list of numbers rented from Apifonica
    • Fill in “to“ parameter - a number which receives the call (point 1)
    • Choose “Controller“ parameter – find in the list of created applications the name of the application in which a link to the XML file is set up (point 2).
  3. You can also use the test script provided in this example to test parallel call functionality by entering the Application SID of the application you have registered in Step 2 into the appropriate field of the HTML form.
  4. The call between the customer and the user is connected.
  5. After the recipient accepts the call, the second leg of the call is executed. The two numbers specified in the makeCall section of the XML file are called in parallel. The connection is then established with the number that answers the call first. After the first call is answered, the second one is ignored.
  6. Step 4. Statistics

    1. To get call statistics (logs), please use the console to make a GET request to /accounts/{accountSID}/calls (get call history).
    2. To get the list of expenses, please make a GET request to /accounts/{accountSID}/balance/expenses (get expenses history). You can also get the list of expenses via the personal account.

    You can embed this functionality into virtually anything that supports HTML.