
One of the latest trends is online chat bots. But what to do with those customers who are offline? A large percentage of people prefer to make phone calls. For them, you need either a large staff of operators, or a solution for automation of work with voice. We offer a solution to reduce work and costs (and even almost will not load your programmer).
How to quickly and easily program any voice menu, autoinformer, robot secretary with reference to its customer base?
')
Spoiler: Everything is implemented on webhooks and an example is given in PHP.
Talk under the cut.
What and why?
For example, you have a delivery service or an online store with your own logistics service. Some customers call to find out how their package / merchandise is and they can be easily automated. Similarly, the geo-location of a taxi, the collection of data from the counters, in general, any individual online information that you can give to the client and not waste time on “help” the time of live operators.
To automate this is very simple, we will describe an example below. And, oh, all this can be done absolutely free.
Why not your asterisk?
Of course, everything can be done on Asterisk, but here, in addition to the developer, you will need an administrator, and with knowledge of the security of voice networks (since they are especially loved to be hacked).
We consider the simplest implementation of the solution of the task - on the web.
List of methods
To work, we need only 2 new methods, but each of them provides many opportunities, and most importantly - unlimited cycles. Thanks to the cycles, you can get a voice menu of any depth and an informant on any topic.
Basic methods:
- NOTIFY_START - the beginning of an incoming call to the PBX
- NOTIFY_IVR - the subscriber’s response to the specified action
A detailed description of methods for copy-paste is available
in the API description .
For NOTIFY_START and NOTIFY_IVR requests, you can change the script for the current call on-the-fly by sending one of the following options in response:





In fact, the client calls and listens to the greeting, then dials a specific number (for example, the order number), we send a notification with the numbers that he dialed, the subscriber's script checks the database and sends a response to the notification to us. The response may contain a voice file id or a variant of a standard voice message.
We have a standard number playback system, so there is no need to record a preliminary voice message, that is, the required notification is taken from the database and it is played by the robot as a number. Or you can create up to 100 variants of template voice notifications and send them in response to a client request (your product is in stock, you can receive your product from 9 am to 10 pm every day except Sunday, your package is at the point of issue - Belorusskaya metro station) .
Minimum for implementation
For the secretary to answer, you need at least a phone number and PBX. Also it is necessary to preload or automatically read the secretary's answers.
Customize

- Free PBX for our task is configured in three clicks (choose the desired number of employees, the voice menu can be configured later).
- Telephone numbers for PBX can be connected in any major city of the Russian Federation or in 90 countries of the world. The number is included immediately after checking the documents (if you need documents for this region). You can also connect one of your own numbers for free.
- To read the voice greetings, you need to go to the “Incoming calls and voice menu” section and select the option that suits you best. You can either upload your files or just type the text and the robot will automatically read it. There are 16 languages ​​available and several voices for each language (14 votes for English). You can save up to 100 voice greetings in your personal account.

PHP example
To show the different possibilities we created 4 examples of working with IVR in PHP.
- The system dictates the last 3 digits from CallerID (an example of working with data on the number and pronouncing numbers)
- The user enters a DTMF date of his birth and the system tells how many days before his DR. (Works with DTMF and pronouncing numbers)
- Infinite multi-level menu: the user can press the numbers and get into the next or past menu (for example, any number of voice menus can be made as a simple cycle).
- An example of authorization to obtain balance (useful for many examples of life).
The first three examples are available on
Github . The example contains all the necessary elements, you need to substitute only files with a recipe (which are preloaded or recited in the PBX).
Task 4 : the user is pronounced a voice greeting and asked to enter his identification number, after entering the number, the system pronounces the balance, says goodbye, using a phrase from the list of popular ones, and ends the call.
We give an example of the 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 investigate the need for further expansion of the functionality of the methods and collect feedback; comments are welcome in the comments. In addition, there are many other methods of web and api. Full list is
on the site .