Making outbound calls from the cloud

Voximplant supports calls from any endpoint to the cloud and from the cloud to any endpoint. This way, a traditional phone-to-phone call is split into two "call legs": from the first phone (or SDK) to the Voximplant cloud and from the Voximplant cloud to the second phone (or SDK), with the audio streams from both calls connected via a cloud-based JavaScript code. This quickstart step demonstrates a simple one-leg case where the Voximplant cloud calls a phone number and then generates an audio stream toward the phone via the built-in "text-to-speech" feature.
Modify your cloud-side JavaScript scenario created in the previous quickstart step, it will initiate an outgoing call to your phone number and synthesize speech. To reach a scenario, click newapplication in the Applications section of the main menu, then switch to the Scenarios tab. Use the call log for debugging.
While technically no source phone is involved in calling a target phone number from the cloud, some phone number should be displayed to the callee so that a person can call back. You can specify a number rented from Voximplant or any number you own if you confirm it in the Voximplant control panel.
VoxEngine.addEventListener(AppEvents.Started, (e) => {
 const numberToCall = "+12345678"; // change this
 const confirmedCallerId = "+76543210"; // and this
 const out = VoxEngine.callPSTN(numberToCall, confirmedCallerId);
 out.addEventListener(CallEvents.Connected, () => {
   out.say("Hello from the cloud", {“language”: VoiceList.Amazon.en_US_Joanna});
 out.addEventListener(CallEvents.Disconnected, VoxEngine.terminate);

To start the cloud-side JavaScript code, inside newapplication switch to Routing on the left menu and click Run rule:

The "Run rule" dialog will be displayed. There you can specify a custom data to the scenario (the custom data can also be sent via the HTTP API as demonstrated in the next quickstart step). 

Click the Run rule button to start the scenario.

After some time a call will land on the phone number specified in the JavaScript code. Answer the call and you will hear a synthesized voice from the Voximplant cloud. In case of errors, check the Voximplant JavaScript session log for details.

Next: Using HTTP API to make calls