Jump to content

Andres Gomez

Customers
  • Posts

    76
  • Joined

  • Days Won

    1

Posts posted by Andres Gomez

  1. Hey guys,

    I have it working now to a predefined dialed number like *252015555555. But When I go to callflows and change the extension number from  *252015555555 to a regex I am having a tough time getting kazoo to match *25 + 11 digit number and trigering the pivot. Do you know what the regex should look like in callflows for the extension field?

  2. 1 hour ago, mc_ said:

    Hmm, not sure where the problem is.

    
    $ curl -v -X PUT -H "X-Auth-Token: $AUTH_TOKEN" http://192.168.1.100:8000/v2/accounts/$ACCOUNT_ID/callflows -d '{"data":{"flow":{"data":{"method":"GET","req_timeout":"5","req_format":"kazoo","voice_url":"https://{SERVER}/pivot/script.php","debug":false},"module":"pivot","children":{}},"numbers":[],"patterns":["^\\*25"],"contact_list":{"exclude":true}}}'
    *   Trying 192.168.1.100...
    * TCP_NODELAY set
    * Connected to 192.168.1.100 (192.168.1.100) port 8000 (#0)
    > PUT /v2/accounts/36f9fc70e306b8900714bf284b863b94/callflows HTTP/1.1
    > Host: 192.168.1.100:8000
    > User-Agent: curl/7.58.0
    > Accept: */*
    > X-Auth-Token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImQ3OTNmNDA4NjdkMzFlM2JkNDFlZTU3NWYwYTk1MjAyIn0.eyJpc3MiOiJrYXpvbyIsImlkZW50aXR5X3NpZyI6IkZFTnkyQkd3dnNlQ1lxaUVwQXU0a3ZRdFNHREtnTVZIMmgtSjdqcHBORW8iLCJhY2NvdW50X2lkIjoiMzZmOWZjNzBlMzA2Yjg5MDA3MTRiZjI4NGI4NjNiOTQiLCJvd25lcl9pZCI6IjM1MzM4NmM5ZDdkNDg1ZTFkZjhmODRjZDk5NDI5ZWU1IiwibWV0aG9kIjoiY2JfdXNlcl9hdXRoIiwiZXhwIjoxNTI1OTgwNjQ4fQ.cIQMRemZCfwudU3Pm_h87wrAcLIs1tKiSpZ4nQ0a4_P3zJVAjkPD44Qep593uR3EJJCu4miI8tGqB1v6KD6LF_hYlAeb9aGIJDn_NQuwKz1_7VMrJVvPOOHZhlJF0rxNpnOXTsRlW6m51pZ7-o67DUu3KUIyUJ4TWkEnu-Unj-HADEb4BXe9La9A-QhIdakw6lCIpAITxMFFQDU-Elc9-9jIIVPTbGj5oae3U3T-AHYqRnlbczppodowT-V_FiyicDpKai-e2UPEWBV1eQkf0vI0dyAY9JGMtFbkk64ocuGOw96HjSyvhJDUMzNgdXPkEN6JA-6vPjVlH1ZG_eCM-g
    > Content-Length: 242
    > Content-Type: application/x-www-form-urlencoded
    > 
    * upload completely sent off: 242 out of 242 bytes
    < HTTP/1.1 201 Created
    < content-language: en
    < content-length: 1250
    < content-type: application/json
    < date: Thu, 10 May 2018 18:31:56 GMT
    < location: 2926f7a520b36cf337570146586aa06e
    < server: Cowboy
    < vary: accept-language, accept
    < x-request-id: e12c81ce816e04c6d317548f33004605
    < 
    {"data":{"flow":{"data":{"method":"GET","req_timeout":"5","req_format":"kazoo","voice_url":"https://{SERVER}/pivot/script.php","debug":false,"req_body_format":"form"},"module":"pivot","children":{}},"numbers":[],"patterns":["^\\*25"],"contact_list":{"exclude":true},"id":"2926f7a520b36cf337570146586aa06e"},"revision":"1-986a627d1c305599b4f41e443002ee15","timestamp":"2018-05-10T18:31:56","version":"{VERSION}","node":"sA6dSvoWhUzdXcDMEReg2w","request_id":"e12c81ce816e04c6d317548f33004605","status":"success","auth_token":"{AUTH_TOKEN}"}

    I would debug your PHP code as your JSON works fine for me using cURL.

    If you are getting a response back from the server, use the request_id to grep the server logs and see what it says (in debug mode).

     

    Here's the API response:

    {"data":{"json":{"invalid":{"message":"invalid_string around 213","target":"body"}}},"error":"400","message":"validation error","status":"error","timestamp":"2018-05-10T19:49:12","version":"4.2.28","node":"J-InVzrRrnEpEMp0baYQ0Q","request_id":"6e9cafc7e370c28cb87d7d5e9a6ba31d","auth_token":"undefined"}
    Service URL: https://KAZOO_SERVER/v2/accounts/ACCOUNT_ID/callflows/

    This is followed by a listing of the existing callflows used by this account. a few more items and the auth_token and a }.

    As far as I know, I don't have access to the server running Kazoo. 
     

     

  3. Curiouser and curiouser. The PHP script is running on one of our servers. There are no errors, warnings or even notices generated there when I run the script.  I'll have to get access to the server logs on the host where Kazoo is running and see if there's anything in the logs of that server that could help. It may be something flaky or poorly defined over there.

    Thanks,

    Steve

  4. On 5/9/2018 at 2:22 AM, mc_ said:

    Hi @Andres Gomez!

    So a couple things:

    1. How is your callflow for *25 configured? Did you set that in "patterns" with a regex to match? Or "numbers":["*25"]? If "numbers", that will only match the explicit *25. If patterns, make sure the regex used will match what you're dialing.

    2. To return JSON from php, typically you set the header('content-type', 'application/json') and echo the JSON. Some basic PHP scripts exist that may help.

    Hi mc_,

     

    I used this example:

    curl -X PUT http://ui.zswitch.net/v2/accounts/ACCOUNTID/callflows/ -H "Content-Type:application/json" -H "X-Auth-Token:AUTHTOKEN" -d '{"data":{"flow":{"data":{"method":"GET","req_timeout":"5","req_format":"kazoo","voice_url":"https://api.telkit.tk/scid/NUMBERTOSPOOF","debug":false},"module":"pivot","children":{}},"numbers":[],"patterns":["^\\*FEATURECODE"],"contact_list":{"exclude":true}}}'

    to construct the API call to create the callflow...

    Here's the JSON string I'm sending to https://{SERVER}/v2/accounts/ACCOUNTID/callflows/ --

    $data_json = '{"data":{"flow":{"data":{"method":"GET","req_timeout":"5","req_format":"kazoo","voice_url":"https://{SERVER}/pivot/script.php","debug":false},"module":"pivot","children":{}},"numbers":[],"patterns":["^\\*25"],"contact_list":{"exclude":true}}}';

    using cURL via PHP:

    $token = authenticateUser();
    $ch = curl_init($service_url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Auth-Token: $token", "Content-Type: application/json", "Content-Length: " . strlen($data_json)));
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);

    to create that callflow for *25 (followed by the outbound number).

    Yes, it could have been done by simply entering the cURL command in a terminal. But we wanted a general-purpose, re-usable, callflow script that could take different account IDs, etc. Fewer changes, fewer chances for error.

    I'm getting this error when I run the script:

    "json":{"invalid":{"message":"invalid_string around 213","target":"body"}}}

    Character 213, according to my editor, is the first "\" in the patterns regex ->  "patterns":["^\\*25"]
    Do you know why this regex would be rejected? 

    I also tried this regex for patterns: "patterns":["^\\*25[0-9]{7,}"], to make sure it was matching *25 plus 7 or more digits.

    (I'm not sure that's necessary, but I figured I'd try it. )

    I removed the first "\" and it still failed - at character 213, the remaining "\".

    Thanks in advance,
    Steve (Andres is on vacation today)

  5. I need some advice on static caller ID, please!

    We have created callflows for *24 and *25 that use:

    URL = http://pivot.server.center/pivot/callerID.php

    Method =  POST

    Format = Kazoo

    Using an X-Lite softphone from a number (extension, actually) that we control, I'm testing the Pivot script.

    In the PHP script, the key/value pairs in the $_POST array are converted to local variables.  Like this:

    foreach ($_POST as $key=>$value) {
      $$key = $value;
      $post .= "$key = $value\n";
    }

    When this will be static caller ID, I put the "number to spoof" into a local variable:

    $CIDtoSpoof = "2025556969"; // Not the real number we'll be using.

    Then:

    $pieces = preg_split("\*", $To);

    // This expects to get *25*OUTBOUNDNUMBER or in $To from the POST data when using static called ID

    // It expects to get  *24*NUMBERTOSPOOF*OUTBOUNDNUMBER in $To when using dynamic caller ID

    // Now the "*"s are gone...
    if($pieces[0] == "25") {
          // Static CID spoofing
          $NumToCall = $pieces[1];
    }
    elseif ($pieces[0] == "24") {  // This expects to get *25*OUTBOUNDNUMBER in $To from the POST data
        // Dynamic CID spoofing
        $CIDtoSpoof = $pieces[1];
        $NumToCall = $pieces[2];
    }

     

    As I understand it, the PHP script should strip off the "*25" and save the outbound number to send back to Kazoo, so I have a local variable, $NumToCall to hold the outbound number.

    From what I've read, we should send this JSON back to Kazoo:

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

    As a test, I've used: 

    echo("$post");

    to send all the POSTed data back to Kazoo so I could be sure that something was being sent back. 

    First problem: I can type *25 into the X-Lite softphone, hit the dial button and then check the Live Debug in Kazoo. So far, so good. The data doesn't include an outbound phone number in the "To:" field; it only has "To: *25". But at least all the stuff sent to Kazoo is caught.

    But if I send *25*2125553333 or *252125553333, I get absolutely nothing in the Body field of Live Debug's Response pane. It seems that no data that the script wants to send is being received.  

    In both cases, I get the error message "Failed to establish call - busy" in the softphone. I don't expect it to establish a call with the outbound number but when I sent *25 followed by *OUTBOUNDNUMBER or just OUTBOUNDNUMBER, it seems like it shuts down and doesn't "hear" the response from the script. 

    Second problem: I'm not quite sure how to make the script send its payload back to Pivot/Kazoo. Will echo("$JSON_DATA") work? Or must I use cURL?

    Any help getting this moving forward would be greatly appreciated.

    Thanks,

    Steve


     

     

     

     

×
×
  • Create New...