SIGN UP

HowTo's

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 >>>

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 >>>

Step-by-step call center tutorial part 8

Call lists, PDS and SIP

There are two ways how Voximplant can handle an outgoing call. First, the outgoing call can be initiated from JavaScript session created from the incoming call. That approach is used if you want to connect two or more people, forward call into a call center or implement any other "connect two persons" logic where and outgoing call is initiated as a response to the incoming call. Second, you can initiate outgoing call via the HTTP API. That approach is used if you want to initiate a call from your service or call multiple users. You can implement any call logic via HTTP API, but you also need to setup your own backend that will initiate calls, maintain the suitable number of simultaneous calls etc. For fast "out-of-the-box" experience we have a built-in "Call list" functionality that allows calling thousands of users with a few commands and without any backend of your own.

read more >>>

Step-by-step call center tutorial part 7

Operator status and temporary ban

While Voximplant ACD framework provides only essential call center backbone, it also has some out-of-the-box features for most popular use cases. One of such features is "Operator Status" that can be set to "Ready" if operator is available to handle a call, or any one of non-"Ready" if calls should not be forwarded to that operator.

read more >>>

Step-by-step call center tutorial part 6

IVR and operator skills

In a simple scenario all incoming user calls are evenly distributed among all available operators. But as a number of users grows, it became more convenient to direct specific requests to specific operators who can handle them better. This raises a number of questions: how to figure out user question and how to define which operator can answer that questions.

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.