Asterisk Call Back

Posted on 2011-10-12
Last Modified: 2013-12-21
Hi guys,

I hope you can help i have a asterisk 1.6 box and i want to enable a callback where if one of my people phones the pabx it gives the engaged signal and then phones them back.

I have seen and tried many guides to do this but just cant seem to get it working. Do you have any suggestions / examples.

Thanks very much

Question by:frankie_jnr
    LVL 36

    Expert Comment

    What methods have you tried?

    Personally the way I prefer to do it is have the dialplan call an AGI program whicl then creates a corresponding .call file. Asterisk then sees this .call file and dials the appropiate number.
    These solutions are normally a little more complex as the caller may be witholding their callerid so asterisk will need to detect this and ask for a number to be called back on.
    Also some callers may be phoning from a company where the general company switchboard number is provided so they may want to provide an alternative direct dial number or leave a recorded message for you telling you who to ask for when you get through.

    Lets get the basic functionality working first and then you can add the extra feature later.
    LVL 36

    Accepted Solution

    Here is an example AGI script. You simple call it from the dialplan using the AGI command and pass it the number to be dialled.
    It then creates a call file telling it to dial the given number in the 'outgoingcall' contest and then once answered connect the call to the 'agents' extension in the 'callback' context which could then pass the call onto one of your agents.
    You can swap it around aswell so your agent is called first and then it tries to call the person asking for the callback. It all depends on how busy your agents are.
    $agivars = array();
    while (!feof(STDIN))
       $agivar = trim(fgets(STDIN));
       if ($agivar === '')
       $agivar = explode(':', $agivar);
       $agivars[$agivar[0]] = trim($agivar[1]);
    # write new call file here
    $myFile = "/tmp/" .$callerid .".call";
    $fh = fopen($myFile, 'w') or die("can't open file");
    fwrite($fh, "Channel: Local/agent1@callback\n");
    fwrite($fh, "MaxRetries: 0\n");
    fwrite($fh, "RetryTime: 15\n");
    fwrite($fh, "WaitTime: 15\n");
    fwrite($fh, "Context: outgoingcall\n");
    fwrite($fh, "Extension: " .$callerid ."\n");
    rename("/tmp/" .$callerid .".call","/var/spool/asterisk/outgoing/" .$callerid .".call");

    Open in new window


    Author Closing Comment

    Thank you so much

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    Free PBX 3 54
    Linksys e2000 router 10 59
    surface mount resistors 7 61
    How to determine the cell phone carrier 3 36
    Healthcare providers, insurance companies and other covered entities trust eFax Corporate to transmit their most sensitive documents. eFax Corporate can help your organization implement a HIPAA compliant cloud faxing solution.
    Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now