Making calls using HTTP API

Usually call is initiated by client SDK, SIP endpoint or received on the platform because somebody called phone number connected to VoxImplant. But there are couple of scenarios when call needs to be initiated without someone making a call from SDK or any other endpoint. The most common ones are callback, automated information systems, etc.

To start call scenario you need to invoke StartScenarios function of HTTP API. There's one mandatory argument that should be mentioned - rule_id. Rule_id is the identifier of some Rule in one of your applications. You can obtain it by calling GetRules function of HTTP API.

After scenario has been started, session is created and AppEvents.Started event is dispatched, so you need to add handler for this event and do all further actions after it was called.

After you've created a session, you can interact with it by making HTTP requests directly to the session. To make it possible, StartScenarios function returns media_session_access_url value. This URL lets you control the session. When you make HTTP request to this URL, AppEvents.HttpRequest event is dispatched in your scenario. You can process it, and return some data to the client as HTTP response.

For example, this code returns static JSON to the client, but logic can be way more complicated since you have access to request URL and POST body.

  1. VoxEngine.addEventListener(AppEvents.HttpRequest, function (e) {
  2. return {"value":"This is how we handle HTTP requests"};
  3. });