ВОЙТИ

Apps, Scenarios, Rules and Users

Applications

The main entry point to managing your account is the Applications section. Applications group multiple JavaScript scenarios under a single unique name. This name is then used as an "access point" for connecting phone numbers, targeting SIP calls, attaching platform features like "call queues" and so on. To create an application, you need to be registered at the Voximplant control panel:

https://manage.voximplant.com

During the registration, you will need to define a unique username (also known as the "account name") and specify an email to receive platform notifications. You can change notifications or add more emails later using the "Contacts" control panel section. After registering and logging in, open the control panel, open the main menu in the upper left corner, choose Applications, then click New application in the upper right corner.

This will open the New application editor window where you should enter the application name and confirm by clicking Create. The application will appear in the application list. To edit a newly created application, just click on it to enter the application editor. To change the application's name, icon and description, use Edit in the application menu.

JavaScript cloud scenarios

The Voximplant architecture is based on scenarios, that is, a modern ES2017 JavaScript code created by a customer and executed automatically upon receiving an incoming call or the backend request. This code has access to standard JavaScript features alongside with VoxEngine API. That API allows to control voice and video calls in real-time from the running JavaScript code and use Voximplant built-in features like recording, text-to-speech and more. To create a scenario, in your application select Scenarios on the left menu and click on the plus icon – this is the New scenario button:

Then enter a name for a scenario and press Enter.

This will open the online IDE in the left side of the screen. IDE allows you to write the source code. If needed, you can rename the scenario or change the source code later, or upload them automatically via the HTTP API. At this step, name your scenario ‘callcenter’ and enter the following source code:

VoxEngine.addEventListener(AppEvents.CallAlerting, e => {
 // this code is executed in the cloud on every incoming call
 e.call.startEarlyMedia();
 e.call.say("Hello from the cloud", Language.US_ENGLISH_FEMALE);
});

Pay attention, that there is a Shared folder in the scenarios list. By default, each created scenario is bound to an application. If you want to use a scenario in other applications, right-click on it and choose Move to shared.

The Voximplant cloud platform is fully asynchronous: there are no waiting or blocking operations. All method calls start corresponding operations and return immediately. If you place two "say" methods one after another, the second playback will immediately replace the first one.

You subscribe to events, schedule actions, and your code is called when some event happens. The code starts with the addEventListener method of a global VoxEngine object. The method allows subscribing to global events, and here we subscribe to CallAlerting so that the handler function will be called in the cloud right after an incoming voice or video call arrives.

After the call arrives, we have full control over it via JavaScript. We can inspect the caller’s phone number, answer or reject the call, deliver some audio to the caller and so on. In this example, we are calling the startEarlyMedia method of the call object to inform the caller’s phone service provider that we want to send some audio to the caller. Then we call the say method to synthesize voice from text. Note that we need to answer a call if we want to send any audio into it.

Rules

"Rules" group scenarios within an application and provides a way to start one or more scenarios via HTTP API or via an incoming phone call. Any incoming call has two numbers associated with it: "caller id", which is the number of a person making the call, and "dialed number", which is a number being called. On an incoming call, Voximplant will execute scenario(s) associated with the first rule whose "pattern" regular expression matches "dialed number". If multiple scenarios are assigned to one rule, they are executed one after another in a single context, allowing to re-use common JavaScript code. To create a rule, switch to the Routing tab of the application and either click Create in the center of the screen or New rule in the upper right corner.

This will open the Create rule editor where you can enter a rule name and select JavaScript scenarios. For quickstart examples, name the rule ‘incoming’ and click the ‘callcenter’ scenario created previously – the rule appears in Assigned Scenarios. Click Add to confirm the rule creation.

Users

User credentials are used to accept and initiate calls with non-PSTN endpoints: Web pages with our Web SDK, Android and iOS devices with our mobile SDKs and SIP-enabled software or hardware devices. Users can be created programmatically via HTTP API or via the control panel: switch to the Users tab in the application and either click Create in the center of the screen or Create user in the upper right corner.

Next: Receiving and handling calls in the cloud