Transfering so as to use callerid for dialing patterns

I have multiple phone numbers that come in like:


I would like to extract the callerid and transfer it to another context so that I can use dialing patterns to match phone numbers for who the call should be transferred to.

Using asterisk 1.3

There is no version 1.3 of open source asterisk.

Caller ID is available as the value of the function ${CALLERID(num)}. You can also use the ex-girlfriend matching logic.

You may also want to look at the Goto dialplan application.

Sorry Asterisk 13.8

I have seen if then logic like that but I used to have an ATA on a phone like that would deliver the calls by caller ID.

What I want to do I think would be:

exten=>310-555-1111,1,Goto(context-310-555-1111, 1, $callerid)

exten=>s,1,Action() ; default caller

I was thinking to do it that way just because it would look cleaner. Something like the above may work if I get the syntax right. Not sure if the Goto will work if destination doesn’t exist though.

Goto with a non-existent destination will go to extension i. I’m not sure if that is in the new or the old context.

You should look at ‘ex-girlfriend logic’

I do something like this to only allow calls from inside my state to reach my DID.

exten => 7132/_480NXXXXXX,1,Goto(RING)
exten => 7132/_520NXXXXXX,1,Goto(RING)
exten => 7132/_602NXXXXXX,1,Goto(RING)
exten => 7132/_623NXXXXXX,1,Goto(RING)
exten => 7132/_928NXXXXXX,1,Goto(RING)
exten => 7132,1,Voicemail(7132,u)
exten => 7132,n,Hangup()
exten => 7132,n(RING),Macro(stdexten2,ls,sb-operator,7132,,SIP/7132,6)

For your example you could do

exten=>3105551111/3106661234,1,NoOP(Special Case 1)
exten=>3105551111/3106665678,1,NoOP(Special Case 2)
exten=>3105551111,1,NoOP(Default Action)

That does look pretty clean done that way and probably what I will use. But I still think it would be useful to learn how to transfer to other contexts using caller id. Alas I am busy all week and don’t think I will get to it until next weekend.