Set Caller ID Dynamically

Hello again everybody,

I’m running FreePBX 2.10.0 and installed the Custom Destinations and Custom Estensions module in an attempt to setup dynamic caller ID. We have a few inbound phone numbers hitting the asterisk box, and some phone users require that they make calls with a specific phone number (or Caller-ID).

I’ve been unable to get this working thus far so I was wondering if anyone had done this, and can provide an exact configuration. I would imagine that this would work via a dial-plan where the caller would dial certain digits prior to the phone number thus selecting the specific caller-ID or outgoing line.

Thanks in advance for your help!

Jim

Sorry, wrong answer…removed my answer

Here’s what i suggest you can try:

  1. Define prefixes for dialling (say 11 is the prefix followed by the dest)
  2. for each prefix, user the [macro-dialout-trunk-pre-hook]
  3. Using ExecIf ${EXTEN:0:2} equals to 11, then set caller ID = something

Thanks sanjayws, can you elaborate more?
I’m guessing I would add this in the custom extensions file extensions_custom.conf.

How would the syntax look exactly?

Say I wanted to make this a global option, such that whichever extension dialed “11” before the 10-digit number it would utilize a specific callerID, or an extension dialed “12” they would show another callerID for outgoing calls. Or if we had to do this per extension, say we are using extension 225.

Thanks again.

Jim

I would try something like this, edit extensions_custom.conf, add this macro at the top

[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(Fixing CIDs as per prefix)
exten => s,n,Noop(Prefix is ${EXTEN:0:2})
exten => s,n,Set(USERPREFIX=${EXTEN:0:2})
exten => s,n,ExecIf($["${USERPREFIX}" = “11”],Set,CALLREID(num)=01234567)
exten => s,n,MacroExit()

for extension model
[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(Fixing CIDs as per extension)
exten => s,n,Noop(This extension first two digits are ${AMPUSER:0:2})
exten => s,n,Set(USEREXTEN=${AMPUSER:0:2})
exten => s,n,ExecIf($["${USEREXTEN}" = “22”],Set,CALLREID(num)=9876541)
exten => s,n,MacroExit()

Change the CALLERID(num) parts and other parts that you need to.

Give it a try …

So I tried using the 22, fixed some typos, but I get cannot-complete-as-dialed&check-number-dial-again,noanswer in the logs if I dial “221235551212” Just putting the 22 in front of the 10 digit number.

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Fixing CIDs as per extension)
exten => s,n,Noop(This extension first two digits are ${AMPUSER:0:2})
exten => s,n,Set(USEREXTEN=${AMPUSER:0:2})
exten => s,n,ExecIf($["${USEREXTEN}" = “22”],Set,CALLERID(num)=9876541)
exten => s,n,MacroExit()

Am I going about this right?

Thanks again!

Also in the FreePBX Store there is a commercial module for this if you are looking for a paid product. http://schmoozecom.com/caller-id.php

Lets support the good effort of Tony and team, lets get the paid module. I am sure it will work right away.

If you still want to do the hard way, then show us the log when you do a call now.

add the following line after NoOp before you call.

exten => s,n,DumpChan

I figured out another way to do it. But here’s the log of where it’s failing. After that I explained what I did that should work for me.

[2012-06-02 14:42:00] VERBOSE[28824] pbx.c: – Executing [[email protected]:1] ResetCDR(“SIP/100-00000000”, “”) in new stack
[2012-06-02 14:42:00] VERBOSE[28824] pbx.c: – Executing [[email protected]:2] NoCDR(“SIP/100-00000000”, “”) in new stack
[2012-06-02 14:42:00] VERBOSE[28824] pbx.c: – Executing [[email protected]:3] Progress(“SIP/100-00000000”, “”) in new stack
[2012-06-02 14:42:00] VERBOSE[28824] pbx.c: – Executing [[email protected]:4] Wait(“SIP/100-00000000”, “1”) in new stack
[2012-06-02 14:42:01] VERBOSE[28824] pbx.c: – Executing [[email protected]:5] Progress(“SIP/100-00000000”, “”) in new stack
[2012-06-02 14:42:01] VERBOSE[28824] pbx.c: – Executing [[email protected]:6] Playback(“SIP/100-00000000”, “silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer”) in new stack
[2012-06-02 14:42:01] VERBOSE[28824] file.c: – <SIP/100-00000000> Playing ‘silence/1.ulaw’ (language ‘en’)
[2012-06-02 14:42:02] VERBOSE[28824] file.c: – <SIP/100-00000000> Playing ‘cannot-complete-as-dialed.gsm’ (language ‘en’)
[2012-06-02 14:42:05] VERBOSE[28824] file.c: – <SIP/100-00000000> Playing ‘check-number-dial-again.gsm’ (language ‘en’)
[2012-06-02 14:42:07] VERBOSE[28824] pbx.c: – Executing [[email protected]:7] Wait(“SIP/100-00000000”, “1”) in new stack
[2012-06-02 14:42:08] VERBOSE[28824] pbx.c: – Executing [[email protected]:8] Congestion(“SIP/100-00000000”, “20”) in new stack
[2012-06-02 14:42:08] WARNING[28824] channel.c: Prodding channel ‘SIP/100-00000000’ failed
[2012-06-02 14:42:08] VERBOSE[28824] pbx.c: == Spawn extension (from-internal, 2215551212, 8) exited non-zero on ‘SIP/100-00000000’
[2012-06-02 14:42:08] VERBOSE[28824] pbx.c: – Executing [[email protected]:1] Hangup(“SIP/100-00000000”, “”) in new stack
[2012-06-02 14:42:08] VERBOSE[28824] pbx.c: == Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/100-00000000’

I disabled the above [macro-dialout-trunk-predial-hook] and just made changes int the outbound routes section. eg. I created a “33_outside” outbound route. and added a 33 to the prefix of the outgoing call. Then enabled “override extension”, and set the caller ID for that particular outbound route. Here’s the code.

[outrt-4] ; 33_outside
include => outrt-4-custom
exten => _33.,1,Macro(user-callerid,LIMIT,)
exten => _33.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _33.,n,ExecIf($["${KEEPCID}"!=“TRUE” & ${LEN(${TRUNKCIDOVERRIDE})}=0]?Set(TRUNKCIDOVERRIDE=7085591212))
exten => _33.,n,Set(_NODEST=)
exten => _33.,n,Gosub(sub-record-check,s,1(out,${EXTEN},))
exten => _33.,n,Macro(dialout-trunk,2,${EXTEN:2},)
exten => _33.,n,Macro(outisbusy,)

just create multiple outbound routes with the different prefixes and set the callerid on the outbound route.

The commercial module has some nice features and isn’t as ‘clumsy’ but in either case there’s no reason to do all that custom work when the ability is already there to do it in the route cid. (or with the commercial module)

The paid module works great. It was originally something thry were going to keep on the schmooze side, but after asking (begging) TJ (RIP BUDDY) repeatedly they released it. $150 bucks, well worth it for a point and click solution to change CID via 8codes.