Jump to content

Andres Gomez

Customers
  • Posts

    76
  • Joined

  • Days Won

    1

Posts posted by Andres Gomez

  1. Hello guys,

    Has anyone used the Branch Variable call-flow option through the Monster UI? and if so can you guys share some guidance or business case around it? We tried to use it to enable and disable call-waiting on the server side, and branch out some different flows, but we weren't successful in finding the variables available to be used and whether they work.

    Thanks

    Andres

     

  2. On 3/20/2018 at 11:39 AM, Uzair Mahmud said:

    You can do a pivot script for it.

    for example your code is *8 for group pickup

    to pickup karens call whose extension is say 9001 you would dial *89001 .

    This would go to a pivot script which will get karens $user_id from 9001 

    and return the following json

    '{"module":"group_pickup_feature","data":{"type":"extension","group_id":"'.$user_id.'"}}'

    This would automatically work for picking up any number without having to manually program it

    Here's exactly what we did:

     

    1) Create a callflow/pivot to react to *8 + 4-digit extension:

    curl -v -X PUT -H "X-Auth-Token: " -d '{"data":{"flow":{"data":{"method":"GET","req_timeout":"5","req_format":"kazoo","voice_url":"http://pivot.server/path/to/getGrpExtension.php","debug":false},"module":"pivot","children":{}},"numbers":[],"patterns":["^\\*8([0-9]*)$"],"featurecode":{"name":"Group Pickup","number":"8"},"contact_list":{"exclude":true}}}' http://{KAZOO_SERVER}/v2/accounts/{ACCOUNT_ID}/callflows

    The script getGrpExtension.php looks like:

    <code>

    <?php
    foreach ($_REQUEST as $key=>$value) {
      $$key = $value;
    }
    $accountID = $_REQUEST['Account-ID'];
    if(preg_match('/^\\*8/', $To)) {
      // Strip off the Feature Code (*8) from $To
      $extension = str_replace('*8','',$To);
    }

    header('content-type:application/json');

    ?>
    {
        "module": "pivot",
        "data": {
             "voice_url": "http:/{SERVER}/path/to/verifyExtension.php?extension=<?php echo($extension); ?>&accountID=<?php echo($accountID); ?>"
        },
        "children": {}
    }

    </code>

    As you can see, this script sends the Extension and {ACCOUNT_ID} to the next script.

    The code in verifyExtension.php looks like this:

    <code>

    <?php
    require_once('/path/to/getAuthToken.php');
    $user_id = "";

    foreach($_GET as $key=>$value) {$$key = $value;}
    $extension = $_GET['extension'];
    $accountID = $_GET['accountID'];
    $token = authenticateUser();


    function fetchUserIDs($token, $accountID, $extension) {

      // We're checking for the extension (stored as "presdence_id") that was dialed, among the users of this account. If/when we find a match, we save  the userID to put in the JSON message going back to Kazoo.
      $userID = "";
      $PID = "";
      $service_url = "http://{KAZOO_SERVER}/v2/accounts/$accountID/users";
      $ch = curl_init($service_url);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Auth-Token: $token"));
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      $response = curl_exec($ch);
      if ($response === false) {
        $info = curl_getinfo($ch);
        curl_close($ch);
        die('error occured during curl exec. Additional info: ' . var_export($info));
      }
      $decoded = json_decode($response);
      if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') {
        die('error occured: ' . $decoded->response->errormessage);
      }
      $value = get_object_vars($decoded);
      $data = $value['data'];
      foreach($data as $obj) {
        $PID = $obj->presence_id;
        if($PID == $extension) {
          $userID = $obj->id;
          break;
        }
      }
      curl_close($ch);
      return($userID);
    }

    $user_id = fetchUserIDs($token, $accountID, $extension);
    header('content-type:application/json');

    function valid($user_id){
    // Is it -> "group_id":"$user_id" OR "user_id":"$user_id" ??
    ?>

    {"module":"group_pickup_feature",
      "data":{"type":"extension","user_id": "<?php echo($user_id); ?>"}
    }
    <?php
    }
    if(strlen($user_id) > 1) {valid($user_id);}

    // If we didn't get a valid userID, just quit.
    ?>

    </code>

     

    We've tested this and it works perfectly.

     

     

     

  3. 24 minutes ago, Andres Gomez said:

    I think I found an easy way to do it. I'll post my results after I test it in case someone else needs it. This appraoch wasn't goping to work. What did work was to add a bit of JSON to the script that enters the wakeup call info into the database. 

    In setWakeup.php ...

    <?php

    .

    .

    .header('content-type:application/json');
    ?>
    {
        "module":"play",
        "data":{
            "id": "/56d9ba1fb0250f40eda173e93a0cba0d/e4b7fec7b3bfa1231098def68b049036"
        },
        "children": {}
    }

    6
    15 hours ago, Andres Gomez said:

    Hi!

    We have this script which is run when a customer dials a Spree code to configure a wakeup call:

    <?php

    ?>
    {
        "module":"play",
        "data":{
            "id": "/56d9ba1fb0250f40eda173e93a0cba0d/47080efccc7f31b828ddf75dd94d1d7f"
        },
        "children": {
            "_": {
                "module": "collect_dtmf",
                "data": {
                    "max_digits": 5,
                    "collection_name": "custom_name"
                },
                "children": {
                    "_": {
                        "module": "pivot",
                        "data": {
                            "voice_url": "http://pivot.server.com/pivot/{ACCOUNT}/setWakeup.php"
                        },
                        "children": {}
                    }
                }
            }
        }
    }

     

     

     

  4. Hi!

    We have this script which is run when a customer dials a Spree code to configure a wakeup call:

    <?php
    //$From = $_GET['From'];
    header('content-type:application/json');
    ?>
    {
        "module":"play",
        "data":{
            "id": "/56d9ba1fb0250f40eda173e93a0cba0d/47080efccc7f31b828ddf75dd94d1d7f"
        },
        "children": {
            "_": {
                "module": "collect_dtmf",
                "data": {
                    "max_digits": 5,
                    "collection_name": "custom_name"
                },
                "children": {
                    "_": {
                        "module": "pivot",
                        "data": {
                            "voice_url": "http://pivot.server.com/pivot/{ACCOUNT}/setWakeup.php"
                        },
                        "children": {}
                    }
                }
            }
        }
    }

    Step 1: The person dials the *xx code.

    Step 2: A message is played via TTS, using the "play" module. This message asks them to input the wakeup time in 24-hr format, followed by a "0" for a wakeup today or a "1" for a wakeup tomorrow.

    Step 3: The customer enters the numbers

    Step 4: The pivot script is called. The phone number, wakeup time, today/tomorrow info is saved in the database.

    Step5: Kazoo hangs up the call by making "children":{} the last child of the callflow.

     

    Now this is good and it works fine. But - we'd like to insert another action to play a message letting the customer know that their wakeup call info has been accepted and saved - and hang up after playing that message instead of right after the 5 digits are entered.

    Can someone show me how to insert another "child" similar to:   {"module":"play", "data":{"id": "/56d9ba1fb0250f40eda173e93a0cba0d/47080efccc7f31b828ddf75dd94d1d7f"}} and move the last child

     "children":{}

    to the end of the callflow sequence in this script? I've tried several times to modify the script but haven't gotten the desired result so far. 

    Thanks in advance!

     

     
     

     

  5. Hi fmateo05,

    We were able to implement your solution, up to a point. We're getting the behavior we expected but we've had to store the media files on a different server that the server running Kazoo.

    Can you give us any suggestions, URL pattern, etc. that would allow us to serve the audio files from the same server where Kazoo is running/?

    We uploaded the files to Kazoo, but we're having no luck locating them and getting them to play. I don't think we know the exact path to the uploaded audio files in Kazoo. None of our tests with various paths have had positive outcomes. The paths we tested were of the form:

    http://kazoo-server.com/v2/account/{ACCOUNT_ID}/media/{MEDIA_ID} and

    http://kazoo-server.com/v2/account/{ACCOUNT_ID}/media/audio_file_name.mp3 and

    http://kazoo-server.com/media/audio_file_name.mp3

    etc.

    I suspect that we're using the wrong path to the media files at Kazoo.

    In your pinset.php file, I see this:

    {"module":"play"
       ,"data":{"id":"http://10.10.1.1:8888/wnn/disa-invalid_pin.wav"}
      }

    We were able to make this process work by replacing "http://10.10.1.1:8888/wnn/disa-invalid_pin.wav" with a path to our audio file on an external server. That server is pretty busy, so we'd rather not use it for serving audio files in potentially large numbers. We'd like to know if there's a general path on the Kazoo server, something like:

    http://kazoo-server.com/path/to/invalid_pin.wav.

    Also, we need to know whether it should be a secure path such as http://kazoo-server:8443/etc. We suspect not, but thought it was worth asking.

    Thanks in advance! 

  6.  

    Is it possible to create a pivot using the Pivot app, Numbers Routing screen to make the system respond to *25 followed by any number of digits?

    If so, exactly what do we enter in the Number field of the "Create a new Pivot Callflow" form ?

    We've spent far too much time trying to complete the seemingly simple task.

    Background ---

    This pivot would simply call a script. The script will check for anything that begins with *25 and removes the *25. What remains is the NumberToCall.

    We have chosen a number to appear as the $CIDtoSpoof for any number that begins with *25.

    Thus the script sends this:

     '{
      "children": {
        "_": {
          "data": {
            "to_did": "+1$NumToCall",
            "use_local_resources": false
          },
          "module": "resources"
        }
      },
      "data": {
        "caller_id_number": "+1$CIDtoSpoof"
      },
      "module": "set_cid"
    }'

    We know the script works as designed because we created a Pivot Action for *259194712386 (one specific phone number) and it worked perfectly.

     We used the curl command to create a callflow with the API and data including:

    ... "patterns":["^\\*25([0-9]*)$"],"featurecode":{"name":"CallerIDspoof","number":"25"}, ... and it simply doesn't work. [Note: There are other callflows using similar regex patterns that DO work...! ]

    Not only does this not work, the callflow doesn't appear in the list of Callflows in the Callflows app.
    Callflows created with the Pivot app, Numbers Routing, Create a new Pivot Action although it DOES appear in the response to this API call:

    curl -v -X GET \

    -H "X-Auth-Token: {AUTH_TOKEN}" \

    http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/callflows

  7. The last time I was able to run the command to create the callflow using "patterns" : [ "^\\*25[0-9]*$"], the response said that a callflow using that pattern already existed:

    Command:

     curl -v -X PUT -H "X-Auth-Token: {AUTH_TOKEN}" https://{SERVER}:8443/v2/accounts/47e2f51feb67e1d0303c5ba7cda5e123/callflows -d '{"data":{"flow":{"data":{"method":"GET","req_timeout":"5","req_format":"kazoo","voice_url":"https://{SERVER}:8443/path/to/script.php","debug":false},"module":"pivot","children":{}},"numbers":[],"patterns":["^\\*25([0-9]*)$"],"featurecode":{"name":"CallerID","number":"25"},"contact_list":{"exclude":true}}}' 

    Response:

    {"data":{"patterns":{"unique":{"message":"Pattern ^\\*25([0-9]*)$ exists in callflow 8a9175d8af5b696abba11ecfa917b45c 8a9175d8af5b696abba11ecfa917b45c","cause":"^\\*25([0-9]*)$"}}},"error":"400","message":"validation error","status":"error","timestamp":"2018-05-21T21:03:51","version":"4.2.28","node":"3A84g8C1-SlJxAeyNspJwQ","request_id":"{REQUEST_ID}","auth_token":"{AUTH_TOKEN}*

    However, no such callflow exists (callflow id: 8a9175d8af5b696abba11ecfa917b45c, right?), according to the callflows list in the Callflows app. 

×
×
  • Create New...