Search code examples
asterisk

How to Dial to Originate a Call from Within the Dialplan?


Salvete! How can I dial a number and have Asterisk originate a call from extension sipX to sipY?

Both sipX and sipY appear in extensions.conf of my dialplan.

The trick is that I want to dial 337 on my phone, and then my phone goes out of the picture, then sipX calls sipY.

Say I want to be able to push 337 on the phone, and have a sound played over the speakerphone of another phone, say, as an alarm.


Another way to consider it is, how can I do this:

  1. Push 337 on my phone
  2. complete my call, that is, hang up the original caller
  3. run a macro even though there is no call in queue
  4. call sipY
  5. play a sound on sipY

When running the #2 action (completing the caller's session) and letting the rest of the process complete afterward, can we use something like the pre-dial handlers in Asterisk 11?


Solution

  • Here is the answer. You place Answer as the first part, and end with 'hangup'. That takes care of the "busy signal".

    No AGI. This works.

    [from-internal]
    exten => 3334,1,Goto(AngelusBell,startbell,1)
    
    
    [AngelusBell]
    exten => startbell,1,Answer
    exten => startbell,n,System(asterisk -rx "channel originate Local/callviking@AngelusBell/n extension playbell@AngelusBell")
    exten => startbell,n,Hangup
    
    exten => callviking,1,Dial(SIP/Y,10,D(5))  ;calls my ATA to my paging box and plays 5 tone
    exten => callviking,2,Hangup
    
    exten => playbell,1,Answer
    exten => playbell,2,Playback(custom/angelusbellWAV)
    exten => playbell,3,Hangup