Bounce call and auto dial

I am running Asterisk on one of asterisk appliance and currently have 2 channel devices. I have heard a function from a lot of VOIP provider and I always wanted to create one for me now that I have my own applicance.

Basically, Below is my requirement and I would like to seek advice in how to do it.

  1. You call one PSTN channel connected to asterisk
  2. Asterisk answer with IVR
  3. when you press 9, it will ask for a number that you wish to dial.
  4. Caller keys in the number he wants to dial.
  5. Call will hangup
  6. Asterisk will then call the callers number
  7. Once the caller answers the call, it will then dial the number that he input on step 4 using a different channel
  8. Call will be connected.

I know this is possible since there are a lot of providers doing it. But I am not sure if this is possible on my asterisk version and not sure how to create the concept. I already have an IVR in place just need to create the context that I can add to make this work. Hope someone call help me out and provide a good working context sample.

The reason I want to do this is to save up from outgoing calls since I will be using my cell to trigger the call. I have free incoming but I need to pay for outgoing. Thanks

you should read your number with READ() application and dial the saved variable with DIAL() application . both of them are available in your version . … k+cmd+Read

He needs call files, or something similar, with that version.

I don’t know much about a2billing, but I think it has callback logic included.

Unless this is a small tweak to an existing system, you should use a supported version of Asterisk.

Yes I agree on the call file as that is what I am reading lately. But not sure how to do it. I was wondering if someone got a working context at least I can pattern from. Thanks

A2billing has this feature but I think using a2billing for just two channel is not a good idea unless you need billing too .
with a simple dial plan you can read the variable and create call files .


exten => s,1,BackGround(your_ivr)

exten => 9,1,Read(NumberToCall,Enter_the_number_you_want_to_call,12)
exten => 9,n,Agi(CreateCallFile.php,${CALLERID(num)},${NumberToCall})
exten => 9,n,Hangup()

( first it plays "Enter the number you want to call " , Reads the number you enter and saves it to “NumberToCall” variable and then it will pass your callerID and NumberToCall variables to a php scripts that can create a call file . you can find many examples of php , perl ,etc scripts that create call files in the web )

Sorry, I have been searching some PHP files but can’t find any related to getting the number. I can see PHP for wakeupcall and all those. Another question is the script you created below can bridge the call with using two different channels? I am a bit newbie on AGIs and call file and hoping to point me to the direction. Thanks.

I was able to do this using combination of call files and DISA.

exten = s,1,NoOp(CallBack)
exten = s,2,Playback(goodbye)
exten = s,3,System(echo “${CALLERID(num)}” > /persistent/etc/NumberToCall.txt)
exten = s,4,System(/persistent/etc/
exten = s,5,Hangup

I created a shell script that will create the call file and pass to /var/spool/asterisk/outgoing and it works perfecty


This will auto-dial the caller and initiate a DISA call

NumberToCall=cat /persistent/etc/NumberToCall.txt
echo “Channel: SIP/$NumberToCall\nContext: voicemenu-custom-6\nExtension: 1” > /persistent/staging/

Pass to Asterisk for processing

mv /persistent/staging/ /var/spool/asterisk/outgoing

Clear Call Files

cat /dev/null > /persistent/etc/NumberToCall.txt
cat /dev/null > /persistent/staging/

I think you need to change
echo “Channel: SIP/$NumberToCall\nContext: voicemenu-custom-6\nExtension: 1” > /persistent/staging/
echo -e “Channel: SIP/$NumberToCall\nContext: voicemenu-custom-6\nExtension: 1” > /persistent/staging/

I am using a Atcom Appliance and the “echo -e” doesn’t work at all. But the above works for me just fine.

Very good solution.

Can you please mention how does the “voicemenu-custom-6” context look like?

exten = s,1,NoOp(DISA1)
exten = s,2,Answer()
exten = s,3,Playback(enter-password)
exten = s,4,DISA(/persistent/etc/asterisk/disapasswd.conf)

disapasswd.conf contains the pass codes and the associated dial plan