Voice Secretary on Webhooks



    One of the latest trends is online chat bots. But what to do with those clients who are offline? A large percentage of people prefer to call. They need either a large staff of operators, or a solution for automating voice work. We offer a solution to reduce work and costs (and even almost do not load your programmer).

    How to quickly and easily program any voice menu, autoinformer, secretary robot with reference to your customer base?

    Spoiler: Everything is implemented on webhooks and an example is given in PHP.

    We discuss 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 they are doing with their package / product and this can be easily automated. Similarly - the geolocation of a taxi, the collection of data from meters, in general, any individual online information that you can give to a client and not spend time on “help” time of live operators.

    Automating this is very simple, we will describe an example below. And, ah, all this can be done absolutely free.

    Why not your asterisk?


    Of course, everything can be done on Asterisk, but here, besides the developer, an administrator is also required, and with knowledge of the security of voice networks (since they are especially fond of cracking).

    We consider the simplest implementation of the solution to the problem - on webhooks.

    Method List


    For work, we need only 2 new methods, but each of them gives a lot of 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.

    The main methods:


    • NOTIFY_START - beginning of an incoming call to the PBX
    • NOTIFY_IVR - subscriber’s response to the specified action

    A detailed description of the 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, order number), we send a notification with numbers which he dialed, the subscriber’s script checks the database and sends a notification response to us. The response may contain the id of the voice file or a variant of the standard voice message.

    We have a standard system for reproducing numbers, so there is no need to record a preliminary voice message, that is, the desired notification is taken from the database and it is reproduced 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’s request (your goods are in stock, you can receive your goods from 9 a.m. to 10 p.m. daily except Sunday, your parcel is at the pick-up point - Belorusskaya metro) .

    Minimum for implementation


    For the secretary to be able to answer, you need at least a phone number and a telephone exchange. It is also worth downloading in advance or automatically reading the answers of the secretary.

    Customize




    1. A free PBX for our task is configured in three clicks (select the desired number of employees, the voice menu can be configured later).
    2. Telephone numbers for automatic telephone exchanges can be connected in any large 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 numbers for free.
    3. To read the voice greetings, go to the “Incoming calls and voice menu” section and select the option that is more suitable. You can either upload your files, or simply print the text and the robot will read it automatically. There are 16 languages ​​and several voices available for each language (14 votes for English). You can save up to 100 voice greetings in your personal account.



    PHP example


    To show different possibilities, we created 4 examples of working with IVR in PHP.

    1. The system dictates the last 3 digits from CallerID (an example of working with data on the number and pronouncing the digits)
    2. The user enters DTMF date of birth and the system says how many days before his DR. (Working with DTMF and pronouncing numbers)
    3. Endless multi-level menu: the user can click numbers and get to the next or previous menu (an example of how you can make any number of voice menus with a simple cycle).
    4. An example of authorization to get a balance (useful for many examples from life).

    The first three examples are available on Github . In the example, all the necessary elements are spelled out, you only need to substitute files with a thread (which you must preload or read in the PBX).

    Task 4 : the user says a voice greeting and is asked to enter their 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 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 to further expand the functionality of the methods and collect feedback, suggestions in the comments are welcome. In addition, many other webhook and api methods are available. A complete list is on the site .

    Also popular now: