SIGN UP

Blog

HTTP API callbacks

INTRODUCTION

HTTP Callbacks allow getting important notifications without frequently sending HTTP requests from your backend to the Voximplant cloud. Instead of creating additional scripts that send requests to our HTTP API, it’s more practical to rely on the already existing automation feature, such as allbacks. Voximplant offers you a variety of callbacks and, in this article, we’ll explore how MinBalanceCallback is used. With callbacks, the Voximplant HTTP API becomes even more useful in terms of better integration and monitoring.

WHAT YOU NEED

  • Voximplant developer account. If you don’t have one, sign up here.
  • Basic knowledge of the Voximplant HTTP API.
  • A simple backend. We will use the node.js server as an example.

USING CALLBACKS

Go to the API Access section of the Voximplant control panel. This section contains two boxes: Callback URL and Security salt. Technically, only the Сallback URL box is required to enable callbacks while the Security salt box is optional. However, in this article, we will check the hash, that’s why both boxes must be filled in.

In the Callback URL box, specify the URL of your backend server. The Security salt box can contain cryptographic salt, which is an arbitrary text string up to 40 characters.

A callback will use the Security salt value to calculate the MD5 hash, which is retrieved by your backend server as part of an AccountCallback JSON object.

When you fill in both boxes, click Save. Now you can use the Voximplant callbacks and check the hash.

CALLBACKS IN ACTION

The Voximplant cloud sends the HTTP POST requests with one or several callbacks to your backend server.

The request body will contain an object with the account callback array. The array contains the AccountCallback JSON object with the following fields:

  • type – the callback type that determines which properties contain data. The min_balance type means MinBalanceCallback.
  • hash – the hash calculated by the Voximplant cloud.
  • сallback_id – a unique number of the callback, which is used to calculate the hash.
  • For more information, see the HTTP API documentation.

For example, if the balance reaches the specified threshold, the callback list will contain a MinBalanceCallback callback. The backend server can do anything with that information: send a letter to your support team, store the alert timestamp, etc. The handlers are up to you — set up any handling rules you want. For illustrative purposes, we will write a debug message to the server console.

BACKEND

The Voximplant HTTP API can communicate with the PHP/Node.js/nginx and other backend solutions. To get things done quickly, we will use the Express framework for node.js.

Install node.js and express.js on any server platform (AWS, Azure or any VDS, etc.). You can also test the solution locally using ngrok, which allows testing demo applications from your local computer without deploying them with a public IP address.

Since the Security salt value was set, it’s possible to save it to the backend server to check the hash later. As you can see on the figure in the first paragraph, the MD5 algorithm is used to calculate the hash:

md5(Security salt + account_id + api_key + callback_id)

The backend server stores the Security salt, account_id, and api_key values. When the callback is triggered, the server receives hash and callback_id. Then the server calculates the hash and compares the calculated value with the received one. If the values match, everything is OK; otherwise, the callback is corrupted or triggered not from the Voximplant cloud.

Let’s create the index.js file with the following code:

const express = require('express');
const crypto = require('crypto');

const app = express();
const salt = "<salt string>";
const accountId = "<account id string>";
const apiKey = "<api key string>";

app.use(express.json());

app.post('/', (req, res) => {
  for (callback of req.body.callbacks) {
    const data = salt + accountId + apiKey + callback.callback_id;
    hash = crypto.createHash('md5').update(data).digest('hex');
    if (hash === callback.hash) {
      res.sendStatus(200);
      if (callback.type === 'min_balance') {
        console.log("WARNING! The balance is under the threshold!");
      }
    }   
  }
});

app.get('/', (req, res) => {
  res.sendStatus(200);
});

app.listen(3000);

CONCLUSION

Make your server communicate with the Voximplant HTTP API to get even more control of your account. Receive the alerts on time or check the information manually – the callbacks obviously aid you in keeping the account data close at hand. Enjoy the functionality and stay tuned!

read more >>>

H.264 video call recording is now available (in mp4 format)

h264 avc mp4We are happy to announce that video calls that use H.264 video codec can now be recorded. Recorded video calls that use H.264 will be stored as mp4 files (calls with video in VP8 format are stored as webm files). There are few ways to enable H.264 in your video calls: - Use H264first Config param (Web SDK) - Use H264first flag in CallSettings (Web SDK) - Mobile SDKs are being updated to let developers enable H264 in video calls According to the following research from Chris Koehncke using H.264 instead of VP8 can save up to 50% in terms of power consumption https://www.chriskranky.com/webrtc-impacts-on-battery-life/ , in addition to that mp4/avc is widely used and supported by most players in both online and offline worlds. See the example of video recording below (Firefox->Voximplant, no post-processing) https://vimeo.com/215691569 P.S. Feel free to ping us if you have any problems with video call recording

read more >>>

Authorization using tokens instead of passwords

Storing and saving passwords inside applications is not safe. For better security our SDK provides two additional login methods: with the one-time login keys and with the renewable tokens. Keys omits the need to store passwords entirely by using your own backend that will generate a one-time login key each time your application needs to login the Voximplant cloud. Although very secure, the keys require your own backend to be created, while the "tokens" can be used entirely on the SDK side with some security and usability trade-offs that are explained in this article.

read more >>>

Push Notifications for Android

VoxImplant push notifications for Android are based on FirebaseCloud Messaging (FCM) platform and implemented as the "data messages". Using notifications, a device can be awakened and an app started before a call arrives. Our SDK requires Android API 16 (4.1), while push notifications support also requires Play Services 10.0.1 or higher to be available on the device. Our Android SDK contains a sample application with all the code needed to handle push notification. Following tutorial explains that code and describes additional steps that should be performed to have a working Push Notifications solution for your mobile applications. Push notifications are available since Android SDK version 2.1.0

read more >>>

Push Notifications for iOS

VoxImplant push notifications for iOS are based on the Apple VoIP Push Notifications. Using notifications, a device can be awakened up and an app started before a call arrives. Our iOS SDK contains a sample application with all the code needed to handle push notification. Following tutorial explains that code and describes additional steps that should be performed to have a working Push Notifications solution for your mobile applications. Push notifications are available since iOS SDK version 1.1.0

read more >>>

Speech-to-text: ASR

Unlike transcription that is performed after call ends, ASR (automatic speech recognition) works during a call and allows either to recognize a word among given variants or do a "freeform" recognition of an arbitrary speech.

read more >>>

Audio Recording

Voximplant cloud scenario allows to record audio, video and transcribe voice-to-text for each individual call object. Recorded audio, video or text is stored at Voximplant cloud for 3 months, after that it's automatically deleted. Recordings can be downloaded if longer storage is required.

read more >>>

VoIP Push Notifications support for iOS SDK has arrived

Dear Voximplant developers, we are happy to announce that Voximplant now supports VoIP Push Notifications for calls to iOS SDK. We tried to make everything as simple for developer as possible; the following steps are required to enable VoIP Push Notifications for your app: 1. Upload your Apple VoIP Push certificate at https://manage.voximplant.com/#certificates and specify (bind) Voximplant application(s) where you will be using VoIP Push functionality 2. Add

require(Modules.PushService);

in the beginning of your VoxEngine scenario 3. Now VoxEngine's callUser and callUserDirect functions will start using VoIP Pushes to notify the SDK about incoming calls. (same applies to helper functions: forwardCallToUser and forwardCallToUserDirect) 4. Get new version of iOS SDK at http://voximplant.com/docs/references/mobilesdk/ios/ That's it! P.S. Android Push support is on its way to production, expect it right after the New Year in January 2017!

read more >>>
Get your free developer account or talk with our sales team to learn more about Voximplant solutions
SIGN UP
Contact sales

Please complete this field.

Please complete this field.

Please complete this field.

Choose the solution

Please complete this field.

Please complete this field.