vTiger PBX Manager setup for click to call

Discussion in 'General' started by Maag, Sep 29, 2010.

  1. Maag

    Joined:
    Nov 2, 2008
    Messages:
    4
    Likes Received:
    0
    Just got Elastix 2 installed on my server and it has vTiger 5.1.0 integrated in it. But could not find any info how to configure PBX Manager. After figuring out (not so difficult if you know thing or 2 about trixbox or elastix and AMI)I was able click-to-call local extencions but not SIP outbound trunks. Was saying "good buy".

    So here what I had to do to make it work:

    (make shure you have extencion number under user profile)

    PBX>Tools>Asterisk File Editor

    Open and edit manager_custom.conf:

    [vTiger]
    secret=yourpasswordhere
    permit=127.0.0.1/255.255.255.0
    read = system,call,log,verbose,command,agent,user,dialplan
    write = system,call,log,verbose,command,agent,user,originate

    Connect to SSH and:

    su -
    asterisk -r
    manager reload
    manager show user vTiger

    In vTiger go to Module Manager>PBX Manager>Edit


    Asterisk server IP: 127.0.0.1
    Asterisk server port: 5038
    Asterisk username: vTiger
    Asterisk password: yourpasswordhere

    Edit file /var/www/html/vtigercrm/modules/PBXManager/utils/AsteriskClass.php
    and find "$context =" and replace with "$context = "from-internal";"

    >nano /var/www/html/vtigercrm/modules/PBXManager/utils/AsteriskClass.php


    /**
    * create a call between from and to
    * @param string $from - the from number
    * @param sring $to - the to number
    * this function prepares the parameter $context and calls the createCall() function
    */
    function transfer($from,$to){
    $this->log->debug("in function transfer($from, $to)");
    if(empty($from) || empty($to)) {
    echo "Not sufficient parameters to create the call";
    $this->log->debug("Not sufficient parameters to create the call");
    return false;
    }

    //the caller would always be a SIP phone in our case
    if(!strstr($from,"SIP")){
    $from = "SIP/$from";
    }
    if(strpos($to, ":")!==FALSE){
    $arr = explode(":", $to);
    if(is_array($arr)){
    $typeCalled = $arr[0];
    $to = trim($arr[1]);
    }
    }

    switch($typeCalled){
    case "SIP":
    $context = "from-internal";
    break;
    case "PSTN":
    $context = "from-internal";//"outbound-dialing";
    break;
    default:
    $context = "from-internal";
    }
    $this->createCall($from, $to, $context);
    }


    Thats it. Click-to-call worked for me. Hope this helps somebody.
     
  2. dai_ig

    Joined:
    Oct 8, 2010
    Messages:
    4
    Likes Received:
    0
    Thanks!! It works perfect!
     
  3. okar

    Joined:
    Jan 13, 2011
    Messages:
    4
    Likes Received:
    0
    Thanks man iam Mexico, I did what you said and it worked, thank you!
     
  4. skin_head77

    Joined:
    Jan 26, 2011
    Messages:
    6
    Likes Received:
    0
    Hi, I'm from chile and my English is not very good but in end.

    my question is I need to do click to call via web service and I have mounted elastix on a machine, you would be very kind to help me to get this service but I want to do something like this. but not in flash, if not with PHP.

    Greetings.


    example

    in spanish

    hola, soy de chile y mi ingles no es muy bueno pero en fin.

    mi pregunta es que necesito hacer un servicio clic para llamar via web y ya tengo montado elastix en una maquina, tu serias muy amable de ayudarme para lograr este servicio mi idea es hacer algo como esto. pero no en flash si no con PHP.

    Saludos.
     
  5. fmvillares

    Joined:
    Sep 8, 2007
    Messages:
    1,785
    Likes Received:
    0
    welcome to the club that really help here! and studying or searching also ... you diserve my karma upgrade!
     
  6. mm.alpha2k

    Joined:
    Jun 19, 2010
    Messages:
    165
    Likes Received:
    0
  7. Maag

    Joined:
    Nov 2, 2008
    Messages:
    4
    Likes Received:
    0
    There are bunch of scripts online for that.
    Here is one I am using:
    (just create click2call.php, check permissions, copy paste all this and change settings in it the way you need it (like vTiger password))

    <html>
    <head>
    <title>Click2Dial</title>
    </head>
    <body>
    <?php
    #Based on the Click-To-Call script brought to you by VoipJots.com
    #Modified by Rafael Cortes for Asterisk PBXS www.asteriskpbxs.com
    #Slightly modified by NerdVittles.com for your calling pleasure.

    #------------------------------------------------------------------------------------------
    #edit the below variable values to reflect your system/information
    #------------------------------------------------------------------------------------------

    #specify the name/ip address of your asterisk box
    #if your are hosting this page on your asterisk box, then you can use
    #127.0.0.1 as the host IP. Otherwise, you will need to edit the following
    #line in manager.conf, under the Admin user section:
    #permit=127.0.0.1/255.255.255.0
    #change to:
    #permit=127.0.0.1/255.255.255.0,xxx.xxx.xxx.xxx ;(the ip address of the server this page is running on)
    $strHost = "127.0.0.1";

    #specify the username you want to login with (these users are defined in /etc/asterisk/manager.conf)
    #this user is the default AAH AMP user; you shouldn't need to change, if you're using AAH.
    $strUser = "vTiger";

    #specify the password for the above user
    $strSecret = "vTigerpassword";

    #specify the channel (extension) you want to receive the call requests with
    #e.g. SIP/XXX, IAX2/XXXX, ZAP/XXXX, local/1NXXNXXXXXX@from-internal, etc
    #$strChannel = "local/1NXXNXXXXXX@from-internal";Use this for your cell phone Number;
    $strChannel = "local/3001@from-vtiger";

    #specify the context to make the outgoing call from. By default, AAH uses from-internal
    #Using from-internal will make you outgoing dialing rules apply
    $strContext = "from-internal";

    #specify the amount of time you want to try calling the specified channel before hangin up
    $strWaitTime = "30";

    #specify the priority you wish to place on making this call
    $strPriority = "1";

    #specify the maximum amount of retries
    $strMaxRetry = "2";

    #--------------------------------------------------------------------------------------------
    #Shouldn't need to edit anything below this point to make this script work
    #--------------------------------------------------------------------------------------------
    #get the phone number from the posted form
    $strExten = $_GET['number'];
    #
    # $strName = $_POST['txtname'];
    $strExten = $_POST['txtphonenumber'];
    #

    $callNumber = $strExten;
    #specify the caller id for the call
    $strCallerId = "Web-".$strName . " <$callNumber>";

    $length = strlen($strExten);

    if ($length == 10 && is_numeric($strExten))
    {

    $oSocket = fsockopen($strHost, 5038, $errnum, $errdesc) or die("Connection to host failed");
    fputs($oSocket, "Action: login\r\n");
    fputs($oSocket, "Events: off\r\n");
    fputs($oSocket, "Username: $strUser\r\n");
    fputs($oSocket, "Secret: $strSecret\r\n\r\n");
    fputs($oSocket, "Action: originate\r\n");
    fputs($oSocket, "Channel: $strChannel\r\n");
    fputs($oSocket, "WaitTime: $strWaitTime\r\n");
    fputs($oSocket, "CallerId: $strCallerId\r\n");
    fputs($oSocket, "Exten: $strExten\r\n");
    fputs($oSocket, "Context: $strContext\r\n");
    fputs($oSocket, "Priority: 1\r\n\r\n");
    fputs($oSocket, "Action: Logoff\r\n\r\n");
    sleep(3);
    fclose($oSocket);
    ?>
    <p>
    <table width="300" border="1" bordercolor="#0f0f0f" cellpadding="3" cellspacing="0">
    <tr><td>
    <font size="2" face="verdana,arial,georgia"
    color="#000000">Enter 10-digit number (e.g. 7875551234).</font>
    <form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post" name="myform">


    Number: <input type="text" size="30" maxlength="10" name="txtphonenumber"><br><br>
    <body onload="document.myform.txtphonenumber.focus()">
    <center><input type="submit"
    value="Call Me Now"></center>
    </form>
    </td></tr>
    </table>
    </p>








    <?
    }
    else
    {
    ?>
    <p>
    <table width="300" border="1" bordercolor="#0f0f0f" cellpadding="3" cellspacing="0">
    <tr><td>
    <font size="2" face="verdana,arial,georgia"
    color="#000000">Enter 10-digit number (e.g. 7875551234).</font>
    <form action="<? echo $_SERVER['PHP_SELF'] ?>" method="post" name="myform">


    Number: <input type="text" size="30" maxlength="10" name="txtphonenumber"><br><br>
    <body onload="document.myform.txtphonenumber.focus()">
    <center><input type="submit"
    value="Call Me Now"></center>
    </form>
    </td></tr>
    </table>
    </p>





    <?
    }
    ?>
    </body>
    </html>
     
  8. Maag

    Joined:
    Nov 2, 2008
    Messages:
    4
    Likes Received:
    0
    This will dial the number and connect it to extension 3001. I was using it with my gandstream phone with auto answer to quickly call numbers from exel file
     
  9. kingjm

    Joined:
    Aug 5, 2010
    Messages:
    29
    Likes Received:
    0
    the first post worked for me. Awsome thanks so much.
     
  10. acorreaedwards@gmail.com

    Joined:
    Jul 28, 2010
    Messages:
    1
    Likes Received:
    0
    El primer post me funcionó perfecto. Excelente post Maag!!! Muchas gracias.
     
  11. rgranados

    Joined:
    May 22, 2010
    Messages:
    61
    Likes Received:
    0
    I have being receiving Next message from my website, any idea on how to fix, actually with tne vTiger instaled locally is working fine the click-to-call option but with an external installation is not working.



    <b>Warning</b>: fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to 187.160.35.96:5038 (Connection refused) in <b>/home/granados/public_html/crm.helpservice.mx/modules/PBXManager/StartCall.php</b> on line <b>36</b>



    <b>Warning</b>: stream_set_blocking(): supplied argument is not a valid stream resource in <b>/home/granados/public_html/crm.helpservice.mx/modules/PBXManager/StartCall.php</b> on line <b>37</b>

    Socket cannot be created due to error: 111: Connection refused

    Thanks ins advance.
     
  12. dicko

    Joined:
    Oct 24, 2008
    Messages:
    4,099
    Likes Received:
    0
    You need to change the ip address in /etc/asterisk/manager.conf (or one of its included files) of the manager that you defined for vtiger's access, presumably replacing 127.0.0.1, to whatever it should be.
     
  13. rgranados

    Joined:
    May 22, 2010
    Messages:
    61
    Likes Received:
    0
    I did already, before testing...

    i will mount in a different server to discard a firewall issue...

    Will update latter...

    Thanks...
     
  14. danielb

    Joined:
    May 25, 2011
    Messages:
    2
    Likes Received:
    0
    Hey rgranados,

    did you ever solve this issue? I'm having the same problem. I've tried pointing the PBX manager to a different external elastix server and it worked, but it doesn't work with mine (i.e. it's not a matter of manager.conf settings).

    just wondering if you ever figured it out.

    Daniel
     
  15. rgranados

    Joined:
    May 22, 2010
    Messages:
    61
    Likes Received:
    0
    danielb: Sorry, i do not remember because system crashed some days later and i have had to deal with some higher priority isues :blush: .

    I will take a look at the end of the week an let you know. :blush:
     
  16. thedelro

    Joined:
    Feb 9, 2011
    Messages:
    3
    Likes Received:
    0
    I have followed the first post to enable click-to-call.

    I get a "Socket cannot be created due to error: <random number>" right after I click-to-call a local extension and after it says "Outgoing call: pick up the extensions receiver to dial the number."

    I've set in "My preferences" the extension that I'm using already.

    Can anybody help?

    EDIT: nevermind, there was a typo in PBX manager settings. Outgoing works now. I will try it on outside trunks
     
  17. rgranados

    Joined:
    May 22, 2010
    Messages:
    61
    Likes Received:
    0
    Problem with Sockets is a Firewall issue, i have it working with vTiger in same server.
     
  18. drosengarden

    Joined:
    Sep 17, 2011
    Messages:
    26
    Likes Received:
    0
    EDIT: Boy - I am really slow...but hey - I'm a Linux NOOB and I don't really script (just copy ideas and see if they do what I want!) But I got the click to dial working in the 2.2.0 RC2 version (with Asterisk 1.8) on internal extensions. It was the wrong password. Apparently default Admin password in the manager.conf file is elastix456 - even though I never set that! Now I noticed that incoming call from extension didn't do a popup...and I've yet to add my Google Voice trunk for out bound - so we'll see if I can't get that configured too.

    EDIT2: Have incoming popups working but so far only internal extensions tested. I had to run AsteriskClient.php. Didn't know that before this: http://wiki.vtiger.com/index.php/vtiger ... risk_Howto - However NOW the incoming popups are REALLY delayed. I heard AsteriskClient.php is a HUGE resource hog. Any workarounds or better solutions to allow event tracking for just the vTiger pop ups?

    Glad you were able to get it working. Me - not so fortunate.

    My problem is simply just trying to get anything working on the vTiger Asterisk integration.

    I entered info in the PBX Module:


    Asterisk Configuration
    Asterisk server IP 127.0.0.1
    Asterisk server port 5038
    Asterisk username admin
    Asterisk password elastix1
    Asterisk Version 1.4

    I am running the 2.2.0 RC2 beta - this has Asterisk 1.8 I believe.
    But even the Elastix 2.0.3 runs Asterisk 1.6 and I cannot change that Asterisk Version. Even if I select 1.6 it stays 1.4.

    So will this NOT work in the 2.2.0 version of Elastix because it has Asterisk 1.8?

    And then if i need to run 2.0.3 to make it work - it still doesn't let me through.

    I will get one of two errors when I click on the phone number.

    1. Not sufficient parameters to create the call

    or

    2. It tells me it could not log into Asterisk - but when I did the fresh install of Elastix - I used the above referenced password for all password requests during the install. (Do I have the user wrong?)

    Help please!
     
  19. dprado

    Joined:
    Oct 27, 2010
    Messages:
    1
    Likes Received:
    0
    Hello,
    I have a newbie question:

    After this step:
    Code:
    Edit file /var/www/html/vtigercrm/modules/PBXManager/utils/AsteriskClass.php
    and find "$context =" and replace with "$context = "from-internal";"
    I have to insert this module(function) in php file??? or only modify the current file in the line after the first change in step 1??

    Code:
    /**
    * create a call between from and to
    * @param string $from - the from number
    * @param sring $to - the to number
    * this function prepares the parameter $context and calls the createCall() function
    */
    function transfer($from,$to){
    $this->log->debug("in function transfer($from, $to)");
    if(empty($from) || empty($to)) {
    echo "Not sufficient parameters to create the call";
    $this->log->debug("Not sufficient parameters to create the call");
    return false;
    }
    
    //the caller would always be a SIP phone in our case
    if(!strstr($from,"SIP")){
    $from = "SIP/$from";
    }
    if(strpos($to, ":")!==FALSE){
    $arr = explode(":", $to);
    if(is_array($arr)){
    $typeCalled = $arr[0];
    $to = trim($arr[1]);
    }
    }
    
    switch($typeCalled){
    case "SIP":
    $context = "from-internal";
    break;
    case "PSTN":
    $context = "from-internal";//"outbound-dialing";
    break;
    default:
    $context = "from-internal";
    }
    $this->createCall($from, $to, $context);
    } 
    Thanks in advance for any help.
    And I'm sorry for the dumb question :blush:
     
  20. Maag

    Joined:
    Nov 2, 2008
    Messages:
    4
    Likes Received:
    0
    Just edit. Look at the first post. What ever is in red color, you have to edit it.

    P.S. for everybody else, this worked for me on all Asterisk versions 1.4, 1.6 and 1.8
     

Share This Page