An online chatbot is a recent trend on the market. But how to interact with the clients that are offline? A significant percentage of people prefer to interact over the phone. And the business needs either a large staff of operators or a voice communication automating solution. We are offering a solution to reduce workload and costs (and will barely affect your developers’ busyness).
How to rapidly and easily program any voice menu, auto-informant, robot-secretary with an attached client database?
Spoiler alert: everything is done by implementing webhooks and we are using PHP example.
What and why?
For instance, you have a delivery service or an online store with its own logistics in place. Some customers are calling to see what’s with their packages and that can be easily automated. The same goes for cab geolocation, some data collection, or any individual information that can be reported to the client without wasting human power.
It can be easily automated, we’ll provide an example below. Oh, and it can be done completely for free.
Why not your own asterisk?
Of course, it can all be done with Asterisk, but aside from the developer, you will also need an administrator, who is also familiar with voice communication security (as they frequently get hacked).
So we will discuss the simplest way to solve the task – with webhooks.
List of methods
You will only need two new methods for the job, but each of them provides you with a lot of possibilities, and most importantly – unlimited cycles. With the help of these cycles, you can get a multilevel voice menu and an informant for any subject.
Main methods:
- NOTIFY_START — the beginning of an incoming call in PBX
- NOTIFY_IVR — callers’ response to a given action
The detailed method description is available to copy-paste in API description.
For NOTIFY_START and NOTIFY_IVR requests you can change scenarios during the call by responding with one of the options:
So, a client calls and hears the greeting, then dials a certain number (for example, a tracking code), we send a notification with the entered digits, the script checks with the database and sends the response to us. The response can contain a voice file id or a standard voice reply.
We have a standard number playing system, so you don’t have to record a response ahead; meaning, the appropriate notification is chosen from the database and is played as a number by a robot. Or you can create up to a hundred default voice messages and use them to reply to clients (e.g. “Your delivery is at the warehouse”, “You can receive your package every day between 9 a.m. and 10 p.m.).
The implementation minimum
For the responder to answer you need the minimum of a phone number and a PBX. You should also upload or enter the possible responses.
Set up
- Free PBX for this task can be set in three clicks (choose the number of employees and the voice menu can be set later)
- Phone numbers for PBX can be connected from 100 countries around the world. The number connects automatically after ID verification is complete (if it is required for the country of your choice). You can also connect one of your own number for free
- To set the voice menus, go to the “Incoming calls and IVR” page and choose an option that suits you best. Or you can upload your files, or type in a text and the robot will read it automatically. There are 16 languages available with several voices for each one (14 voices in English). You can save up to 100 greetings in your personal account.
PHP example
To demonstrate different options, we have created 4 examples of IVR performance on PHP.
- The system tells last 3 digits from CallerID (example of work with info about numbers and pronouncing digits)
- The user enters their date of birth in DTMF and the system tells how many days left until the birthday (working with DTMF and pronouncing digits)
- Endless multilevel menu: the user can enter digits and get to the next/previous menu (example of how with a simple cycle you can create any number of voice menus)
- Example of authorization to receive the balance status (useful for many life situations)
The first three examples are available on GitHub. There you have all the required elements, you just need to insert the files with the filling (that have to be to prior uploaded to or read in PBX).
Task 4: the caller hears the greeting and is asked to enter the identification number, after entering the system tells the balance, says goodbye using a popular phrase from the list and ends the call.
Here’s an example of code for the described task.
PHP code
$request = new Request();
$notify = self::getEvent([AbstractNotify::EVENT_START, AbstractNotify::EVENT_IVR]);
if (!$notify) {
return;
}
switch ($notify->event){
case AbstractNotify::EVENT_START:
$request
->setIvrPlay(self::INFO_FILE_ID)
->setWaitDtmf(TIMEOUT , ATTEMPTS, MAXDIGITS, DTMF_NAME, DEFAULT_BEHAVIOUR);
break;
case AbstractNotify::EVENT_IVR:
if (!empty($notify->wait_dtmf->digits)) {
$balance = getBalance($notify->wait_dtmf->digits);
$request->setIvrSayNumber($balance, 'en');
} elseif (!empty($notify->ivr_saynumber)) {
$request->setIvrSayPopular(POPULAR_PHRASE_NUM, 'en');
} else {
$request->setHangup();
}
}
$request->send();
We looking to further expand our method features and collecting feedback in the comments below. We also have other webhook methods and API available, you can see the full list on the website.