Making calls to regular phones

Making calls to phones is done in the same manner as Making calls between users.

Here's the example code of the server scenario:

VoxEngine.forwardCallToPSTN();

After you created this scenario you may make call from Web SDK like this:

VoxImplant.getInstance().call("18001234567");

And the call will be made to the desired phone number.

You should keep in mind that VoxImplant thinks that all phone numbers are in the international (E.164) format (country code+area code+number), so if you want to make it possible for a caller to enter a number in some other format, you will need to convert it to the international format. This can be done on the client side (if you use the Web SDK, you can process user input) or in the call scenario.

If you want to do that in the call scenario, you will need to pass an extra parameter to forwardCallToPSTN function:

  1. VoxEngine.forwardCallToPSTN(function(number){
  2. //Process number here
  3. });

This function will accept a dialed number as a parameter and will return the number in the international format. For example, if you want to let people enter a number like they would if they were calling from the United States, you could write the following code:

  1. VoxEngine.forwardCallToPSTN(function(number){
  2. if (number.length > 3) {
  3. if (number.substr(0,3) == "011") {
  4. //Trim long distance prefix
  5. return number.substr(3);
  6. }
  7. }
  8. //Add country code "1" for local and long distance calls.
  9. return number + "1";
  10. });

If you need to handle failures as well, please read the article Advanced call processing.