JavaScript API

Javascript API is allows you to create voice application in JavaScript. You can quickly create Flash based client without really worrying about programming in Flash.

With this, you can place a call or send a SMS using JavaScript without worrying about coding in Flash. You can connect to worldwide phones, SIP servers or even VoicePHP applications using JavaScript.

  • 1. Download the samples from here.
  • 2. Include tringme.js into your webpage or javascript application.
  • 3. Place the tringmejsflash.swf file in the same folder as your Web page.

TringMeCall

This API is used place a call to the destination number.

Parameters
cookie Session validator, ‘cookie’ obtained from Login operation or ‘channel’ obtained from setchannel operation.
number The phone number which you want to call.
x [optional] The X co-ordinate where the flash widget should be aligned when it needs to ask for security settings. If null passed, the widget will appear in the left corner of the HTML document.
y [optional] The Y co-ordinate where the flash widget should be aligned when it needs to ask for security settings. If null passed, the widget will appear in the top corner of the document.
Sample Code to place call when a button is clicked
<input type="button" name="call" id="tringmecallbutton" value="Call" onClick= "TringMeCall('faebdc1029384756cdbeaf', '18558558585', Number(event.clientX - 110), Number(event.clientY -74));" />

Note: Since the flash widget is 220 x 148, 110px and 74px are deducted from x and y to center the widget in the code.

Sample Code to directly place call

TringMeCall ('faebdc1029384756cdbeaf', '18558558585');

TringMeSendDTMF

This API is used send DTMF Input in an on-going call. Useful in IVR applications

Parameters
dtmf A single valid dtmf character, i.e 0-9,#,*.
Sample Code to send DTMF when a button is clicked.
<input type="button" name="dtmf_asteriks" id="dtmf_asteriks" value="*" onClick="TringMeSendDTMF('*');" />
<input type="button" name="dtmf0" id="dtmf0" value="0" onClick="TringMeSendDTMF(this.value);" />
<input type="button" name="dtmf1" id="dtmf1" value="1" onClick="TringMeSendDTMF(this.value);" />

TringMeEndCall

This API is used to terminate on-going call.

Sample Code to end on-going call when a button is clicked
<input type="button" name="dtmf_asteriks" id="dtmf_asteriks" value="*" onClick="TringMeSendDTMF('*');" />
<input type="button" name="dtmf0" id="dtmf0" value="0" onClick="TringMeSendDTMF(this.value);" />
<input type="button" name="dtmf1" id="dtmf1" value="1" onClick="TringMeSendDTMF(this.value);" />

TringMeEndCall

This API is used to terminate on-going call.

Sample Code to end on-going call when a button is clicked
<input type="button" name="end" id="tringmeendbutton" value="End" onClick="TringMeEndCall();" />
Sample Code to directly end call
TringMeEndCall();

TringMeRegisterCallBack

This API is used to get real-time status notification of on-going call. Useful when you need to provide indication that call is in progress or callee is busy, etc.

Paremeters
functionName The name of the function to be invoked when a notification is obtained. Can be String or an instance of the function.
Sample Code to register callback function.
function callbackFunction( status) {
    alert (status);
}
TringMeRegisterCallBack ("callbackFunction");
Sample Code to handle status messages.
function callbackFunction( status) {
    alert(status);
    if( "TringMe.Status.00200" == status) {
        alert( "Call is connected to destination.");
    }
}
TringMeRegisterCallBack( callbackFunction );
Expected Status Code
TringMe.Status.00200 Call Connected Status
TringMe.Status.00204 Call Connecting / Ringing ...
TringMe.Status.00206 Call Ended
TringMe.Status.00207 Destination not Answering / Invalid Destination / Destination Busy

If you are an enterprise and would like to know better how TringMe can help you reduce cost and at the same time benefit you,
please send a mail to bizdev@tringme.com