How to "route" calls to a real number?

Hi, good afternoon guys.

I would like to know which lines could I use to whenever a call goes to a context, this context route the call to a real PSTN number (My cellphone)

I need this because I have a PHP code that, when executed, ‘triggers’ a call to my PSTN number “1234-5678” .

My inbound and outbound calls are already working. I can call outside (using SPA3102) with a VoIP extension. But now I need to fix in this context “arduino call” (Which is connected with the PHP code) a line that always call this cellphone (PSTN number) and play an audio. This already works between PHP > Asterisk > VoIP extension, but I need this for a “PSTN extension”

I already tried with the following contexts and didn’t work out.

exten => 6001,1,Dial(SIP/${REAL NUMBER HERE}@fxo,60,)
exten => s,1,Answer()
exten => s,2,Wait(1)
exten => s,3,Background(Menu2)
exten => s,4,Hangup

exten => REAL NUMBER HERE,1,Dial(SIP/${EXTEN}@fxo,60,)
exten => s,1,Answer()
exten => s,2,Wait(1)
exten => s,3,Background(Menu2)
exten => s,4,Hangup

Has anyone done something similar and could help?

Thanks so much!!

This is confused.

If you can already make outgoing calls via your SIP gateway, you already know all you need to know.

Basically to call the PSTN, number you must have one of:

  • a gateway device connected directly to the PSTN;

  • a PSTN line connected directly to a PSTN line card on your PC;

  • a third party service which is physically connected to PSTN and accessible via VoIP (or I suppose, a private analogue or digital line).

Then use Dial(technology/gateway/PSTN-number), Dial(dahdi/line-or-group/PSTN-number) or Dial(technology/ITSP/PSTN-number), according to which of the above you have. Line-or-group is typically either a number to select an analogue circuit, or primary rate channel, or g for a hunt group.

Ah, ok!!

I tried something right now with this code:

exten => s,2,Dial(SIP/fxo/30323408,60,)
exten => s,1,Answer()
exten => s,2,Wait(1)
exten => s,3,Background(Menu2)
exten => s,4,Hangup

What happened was:
1 - My 6001 voip extension (Which is configured in the PHP. I cant put my directly cellphone number there) started ringing.

2 - When I answered with 6001 phone, it started calling my PSTN-Cellphone number (30323408).

3 - I answered the PSTN phone and my background Menu2 hasn`t played. Instead, it was a normal call between 6001 and PSTN.

All 3 things are wrong…
I dont want a VoIP extension to ring.
I dont want this extension to call my pstn number, I want this automatic.
I want to the background to play in the call with PSTN number.

What I need is to check how could I forward the call directly to 30323408.
Do I need another extension just to forward? How could I do that?

What does “configured in the PHP” mean?

You have two priority 1’s for the same extension. One, probably the second, will get ignored.

The Dial application runs the call and runs for the whole duration of the outbound call. The Background call and associated wait for digits will only be run if the Dial fails, and will always be run on the incoming call.

Although I suspect Originate has a role here, I think you are attempting something way beyond your level of expertise and therefore will need a full commercial level of consultancy, If you are able to pay commercial development rates, you should make a request in the Biz and Jobs forum, but provide a much higher level specification, so that the design is not over constrained.


Got this working now, by simpling editing the line on the PHP file that connects to Asterisk

From (Wrong)
$asterisk_toext = “30323408”; //real number
$asterisk_toext = “6001”; //extension who should have forward the call


$asterisk_toext = “30323408@fxo”; //Real number @ my FXO gateway extension (Using my FXO extension to dial 30323408 outside)

Thanks for the help!