SIGN UP
Navigation

AppEvents

Events

Event is triggered when incoming call arrives. Since each incoming call creates new session, it can be triggered only once during session lifetime

Example

VoxEngine.addEventListener(AppEvents.CallAlerting, function(e) {
    // call handling and other logic
  });

Parameters

  • call:

    Call

    Incoming call that triggered the event

  • callerid:

    String

    CallerID for current call

  • customData:

    String

    Optional: Custom data that was passed from client with the call

  • destination:

    String

    Dialed number

  • displayName:

    String

    Displayable name of the caller

  • fromURI:

    String

    CallerID with domain or SIP URI for incoming SIP call

  • headers:

    Object

    Custom SIP headers received with the call (the ones starting with "X-")

  • name:

    String

    The name of the event - "Application.CallAlerting"

  • scheme:

    Object

    Internal information about codecs, can be passed to the VoxEngine.callUser method call

  • toURI:

    String

    Dialed SIP URI

Event is triggered when the managing HTTP request is received by the session. If you started a call session with HTTP request you got an answer: an object with media_session_access_url property. The property's value is the managing URL for the specified session, so it can be used in managing HTTP request that triggers AppEvents.HttpRequest event. These managing HTTP requests are used to stop scenario or pass additional data into it. For more details see the AppEvents.Started or this article. Example of HTTP request to the media_session_access_url:
curl -d '{"param1": "value1", "param2": "value2"}' -H "Content-type: application/json" -X POST http://185.164.148.244:12092/request/1d61f27ba2faad53.1500645140.80028_185.164.148.244/eb4b0539b13e2401

Parameters

  • content:

    String

    HTTP request content. E.g. '{"param1": "value1", "param2": "value2"}'

  • method:

    String

    HTTP request method. E.g. POST

  • path:

    String

    HTTP path requested (without domain name). E.g. /request/1d61f27ba2faad53.1500645140.80028_185.164.148.244/eb4b0539b13e2401

The very first event is triggered due to incoming call or HTTP request to Voximplant cloud over the internet. The event is triggered only once in a session, so if you execute the same HTTP request again it will create the new, separate session. Note that usage of the event in your JS scenario is optional. See the workflow example in this article.

Example

 https://api.voximplant.com/platform_api/StartScenarios/?account_id=1&api_key=eec36d6c-a0eb-46b5-a006-1c2b65343bac&rule_id=67462  // minimal example of HTTP request
 
 VoxEngine.addEventListener(AppEvents.Started, function() {
   // your code
 });

Parameters

  • accessURL:

    String

    HTTP URL that can be used to send commands to this scenario from outer world

  • accountId:

    Number

    unique identification number of Voximplant account. Can be used as one of the authentication parameters in HTTP API methods.

  • applicationId:

    Number

    unique identification number of Voximplant application. Can be used in Managing Applications methods of HTTP API

  • logURL:

    String

    direct link to the call's log

  • sessionId:

    Number

    unique identification number of JS session. Can be used in Managing History methods of HTTP API

Event is triggered when a session was terminated and after the AppEvents.Terminating event was triggered. The time between these events depends on handler for AppEvents.Terminating event. Use the event just for debugging, only the Logger.write method could be used in a handler.

Event is triggered when a session is about to terminate. The event is triggered in two cases: 1) when there are no calls and/or ACD requests in a call session. See the details in VoxEngine session limits 2) when the VoxEngine.terminate method was called. Timers and any other external resourses are not available after this event was triggered, but you can perform one HTTP request inside the event handler (e.g. to notify external system about the fact that session is finished). When that request is finished (or no such request was made), the Application.Terminated event will be triggered.