Routing different PSTN lines to different extens (no DID)

Greetings!

Being relatively new to Asterisk, I was hoping one of you might be able to give me some insight on this.
I am trying to set up my new system, which has 2 FXO ports (Zap 1, 2) and 2 FXS ports (Zap 3, 4), so that if a call comes in on Zap/1-1, it will be routed directly to a Voice Response System.
This is the easy part. I can get it doing that no problem (thanks to *@H)…

The hard part is this:
How do I set it up so when a call is coming in on Zap 2 it just routes to Zap 4… and on no_answer, goes to VM for that extension?

Prior posts suggested using Incoming DIDs (ie: exten => s/Zap51,n,…) but that didn’t seem to work.

Many thanks in advance for your assistance,

Jay

Have it come in to a diffrent context.

[IncomingZap2]
Exten => s,1,Answer ;Answer the call. You do or do not have to put this in. As a rule I allways do
Exten => s,n,Ringing ; Plays a ringing sound. I believe it is only needed if you use the line above so they hear something instead of nothing once the answer command is use
Exten => s,n,Dial(ZAP/3,30) ; The thiry sets how long it should ring before going to the next line in the dial plan
Exten => s,n,Voicemail(10) ; Where 10 is the extension number
Exten => s,n,Hangup ; When the call is done hangup

Thanks, David, for your suggestion.

That answers the second part of the question. Do you know how to catch which Zap channel the call is coming into the *PBX on?

I am new myself so I haven’t tried this, but take a look at the ${CHANNEL} variable here:

voip-info.org/wiki-Asterisk+variables

Lee

Have you been able to get this working with Asterisk at Home?

For an unknown reason (otherwise, I wouldn’t be posting here), the exten => s,2 command doesn’t seem to work…

It should be noted that my CallerID-based response system works. IE: I have set it up so that if my ex calls in, (her number is specified in the “Caller ID Number:” field), she is transferred into a non-terminated repetitive IVR.

; partial contents of extensions_additional.conf (included from extensions.conf)

[ext-did]
include => ext-did-custom
exten => s,1,Set(FROM_DID=s)
exten => s,n,Set(FAX_RX=disabled)
exten => s,n,Answer
; continued…

; contents of ext-did-custom context in extensions_custom.conf (included from extensions_additional.conf)

[ext-did-custom]
; this will allow calls to be routed by the ZAP channel they come in on.
; example a call comming in on ZAP cahnnel 1 will have Zap1 for it’s DID.

;exten => s,2,GotoIf($["${CHANNEL:0:3}" = “Zap”]?ext-did|Zap${CHANNEL:4:1}|1)
;----------------------- END -----------------------

As per the commented notes, this is supposed to set the “DID” to Zap1 if the call comes in on Zap/1-?, or Zap2 if it comes in on Zap/2-? or the same… However, this context is not even being executed. Since *@H is taking over so many of the functions of this, I can’t seem to get it to even run a custom extension ie: [checkchannel-custom] from the inbound route setup.

When I call into my system with only 2 inbound routes set up (for DID=Zap1 and DID=Zap2), the system hangs up the call. (see log below:)

-- Starting simple switch on 'Zap/1-1'

== Starting Zap/1-1 at from-pstn,s,1 failed so falling back to exten ‘s’
== Starting Zap/1-1 at from-pstn,s,1 still failed so falling back to context ‘default’
– Executing Playback(“Zap/1-1”, “vm-goodbye”) in new stack
– Playing ‘vm-goodbye’ (language ‘en’)
– Executing Macro(“Zap/1-1”, “hangupcall”) in new stack
– Executing ResetCDR(“Zap/1-1”, “w”) in new stack
– Executing NoCDR(“Zap/1-1”, “”) in new stack
– Executing Wait(“Zap/1-1”, “5”) in new stack
– Executing Hangup(“Zap/1-1”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘Zap/1-1’ in macro ‘hangupcall’
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘Zap/1-1’
– Hungup ‘Zap/1-1’


Thanks again for any help you can offer!
Jay

Hi all,

This section of code will route inbound call on Zap channels by the channel number if you change the 2 to a 1 (exten => s,2,… to exten => s,1,…). The correct line should be:

[ext-did-custom]
; this will allow calls to be routed by the ZAP channel they come in on.
; example a call comming in on ZAP cahnnel 1 will have Zap1 for it’s DID.

;exten => s,1,GotoIf($["${CHANNEL:0:3}" = “Zap”]?ext-did|Zap${CHANNEL:4:1}|1)

instead of:

;exten => s,2,GotoIf($["${CHANNEL:0:3}" = “Zap”]?ext-did|Zap${CHANNEL:4:1}|1)

It baffled me for a while. :smile:

this is awsome. all of a sudden problem solved. thank you for pointing out the change from s,2 to s,1

The solution above works fine as long as you do not set the incomming call to goto Default incomming setup.

What I get here when doing this is a continuous loop

Cheers