I am attempting to change the outbound cid for calls that are being forwarded. We have some users who prefer to have their cell phones rang after a predetermined amount of time. In the example below 20 seconds after the call is initiated it forwards to their cell phone. The phone system itself is highly backed up with multiple power and network sources so we want the forwarding to take place on the box and not the endpoints which only have about 30 minutes of backup for their POE switches. This works…
;MY EXTENSION
exten => 4912,hint,PJSIP/4912
same => 1,dial(PJSIP/4912&PJSIP/4923,20,i)
; same => n,Set(_CUSTOM_CID=${CUSTOM_CID}) ; This was used in conjunction with the next entry.
; same => n,Dial(Local/12223334444@redacted-voip) ; <-- See sub note 1
same => n,Dial(SIP/twilio0/12223334444,20,i) ; <-- See sub note 2
same => n,Hangup
Right now if I dial an outside number directly from my handset I get an appropriate caller id being outpulsed by Asterisk. When calls are transferred to a user that originated from outside the building it is passing the original callers CID value. So that works fantastic.
However when I call the users extension from another extension once the 20 second time has elapsed it begins to dial using the dialplan I have setup for 10 digit dialing. And I need the building’s CID value to be passed as the outbound CID value.
; 11 DIGIT DIALING ALL USERS
exten => _1NXXXXXXXXX,1,NoOp(Caller ID Number: ${CALLERID(num)})
same => n,NoOp(Caller ID Name: ${CALLERID(name)})
same => n,Set(outgoing_ident=${DB(OCID/${CALLERID(num)})})
same => n,Set(CALLERID(num)=${IF($[${DB_EXISTS(OCID/${CALLERID(num)})} = 1 ]?${outgoing_ident}:${CUSTOM_CID})})
same => n,NoOp(Reformatted Caller ID Number: ${CALLERID(num)})
same => n,NoOp(Reformatted Caller ID Name: ${CALLERID(name)})
same => n,Answer()
same => n,Dial(SIP/twilio0/+${EXTEN})
same => n,NoOp(DialStatus returned ${DIALSTATUS} and HangupCause returned ${HANGUPCAUSE})
same => n,Hangup(${HANGUPCAUSE})
I know there has to be a way to accomplish this. This is a very vanilla server setup. Asterisk 15.6.2 built by root @ spk-asterisk on a x86_64 running on Deb 9
The CUSTOM_CID is coming from the endpoint setup in pjsip.conf if anyone is wondering.
Sub Notes:
- This works but expects a variable to be passed and I cannot find a way to pass it from the users context. Or rather I can pass it back out but it destroys the inbound callers CID while preserving the internal users outbound CID
- This works only for Outside calls to have their CID passed back out when it finally forwards.
I am sure there will be questions as I know I have likely left more to the wandering mind than I have answered. So please feel free to fire away with more questions. (My carrier supports full CID manipulation! I dont plan to misuse that ability I only use it to pass our phone numbers and those of calls that are forwarded out)
DESIRED OUTCOME
- When I dial extension to extesion I want cid to be that of the internal extensions
- When I dial an extension from within the building I want that extension to ring the called extension and then after 20 seconds it will forward to that users cell phone and show the CID for the building.
- When an ouside caller calls in and is forwarded to an extension it will ring show the outside CID and then when it forwards to the cell phone it will still show the callers CID NOT the building CID.