FreePBX / superfecta

Provides simultaneous use of, and complete control over multiple caller id data sources.
http://www.freepbx.org
GNU General Public License v2.0
59 stars 93 forks source link

Superfecta - Non numeric CID (BT line) #178

Closed myozone closed 10 years ago

myozone commented 10 years ago

I have an issue with Superfecta (2.11.8) FreePBX 2.11.0.10 Asterisk 11.5.1 - Where a non numeric CID ‘Withheld’ Causes Superfecta to return ‘Not a valid number’ Could this be fixed ?

Dave.

[2014-02-12 12:34:09] VERBOSE[16846][C-00000041] res_agi.c: -- Launched AGI Script /var/www/html/admin/modules/superfecta/agi/superfecta.agi
[2014-02-12 12:34:10] VERBOSE[16846][C-00000041] res_agi.c: /var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta is Answering the Channel
[2014-02-12 12:34:10] VERBOSE[16846][C-00000041] res_agi.c: /var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: Scheme is Default
[2014-02-12 12:34:10] VERBOSE[16846][C-00000041] res_agi.c: /var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: The DID passed from Asterisk is: 0123456789
[2014-02-12 12:34:10] VERBOSE[16846][C-00000041] res_agi.c: /var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: The number passed from Asterisk is: LLBT2
[2014-02-12 12:34:10] VERBOSE[16846][C-00000041] res_agi.c: /var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: The CID name passed from Asterisk is: WITHHELD
[2014-02-12 12:34:10] VERBOSE[16846][C-00000041] res_agi.c: /var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: Not a valid number
[2014-02-12 12:34:10] VERBOSE[16846][C-00000041] res_agi.c: -- <SIP/LLBT2-0000007f>AGI Script /var/www/html/admin/modules/superfecta/agi/superfecta.agi completed, returning 0
lgaetz commented 10 years ago

No. From the log lines provided, we can see the inbound call arrives with a CallerID name of "WITHHELD" and a CallerID number of "LLBT2". There is no way that Superfecta can do a number lookup with LLBT2.

myozone commented 10 years ago

Thanks for the reply, I realise Superfecta can't perform a lookup do a lookup on LLBT2, What I'm trying to do is to have FreePBX direct 'Withheld' calls and SF do a 'Send to email' on 'Withheld' calls. I guess if I change 'LLBT2' to the trunk number that should work ?

lgaetz commented 10 years ago

See ticket #165 there is a hack that will force Superfecta to run which may do what you require.

myozone commented 10 years ago

That didn't really work as expected, if I disable Superfecta (remove tick from box) caller ID will display as WITHHELD not LLBT2 - so SF is still messing up WITHHELD calls. Another issue is with FreePBX not having a way to direct a 'WITHHELD' Caller ID other than the ANY/ANY route or a DID route.

lgaetz commented 10 years ago

The reality is that both FreePBX and Superfecta assume that the incoming CID number is numeric. I will not address FreePBX inbound route functionality here, all I can do is offer some Superfecta tips and hacks that MIGHT get you where you want to go.

So you now have Superfecta such that it runs, and returns "WITHHELD" as CID name. Tho that isn't what you expected, that is what I would expect in this situation. The trunk delivers the call with a CID name of "WITHHELD" and since Superfecta can't lookup a better match, this CID name is preserved. If you want to discard that name, you would have to add the Trunk provided module to the top of superfecta and configure it to ignore "WITHHELD". Then configure the Abandon Lookup module at the bottom, and enable the "Use CID" checkbox to force Superfecta to use the CID number for the CID name when no better option is available.

lgaetz commented 10 years ago

Re-reading your post and thinking further, I don't think you are going to get much satisfaction until you change the CID number to something numeric you FreePBX can deal with. If you create your own context and place the BT trunk in this context, then you could use Asterisk code to manually set the CID number to 00000 (five zeros) whenever it comes in with CID number = LLBT2. At the bottom of the file, /etc/asterisk/extensions_custom.conf add lines similar to:

[from-trunk-BT]
exten=>_X.,1,Verbose(3,Entering user defined context [from-trunk-BT])
exten=>_X.,n,Set(CALLERID(number)=${IF($[ ${CALLERID(number)} = LLBT2]?00000:${CALLERID(number)})})
exten=>_X.,n,Verbose(3,Going to context [from-trunk] with Caller ID number ${CALLERID(number)})
exten=>_X.,n,Goto(from-trunk,${EXTEN},1)

Once the CID number is set to 00000 you can structure an inbound route with CID pattern to do what you need.

myozone commented 10 years ago

Thanks for both replies, I see what you mean. I have already a custom context to remove the space and hyphen from the BT landline they sometimes add. I guess I just add you code after that code ? or change all references to LLBT2 to numeric value - don't think that worked when I put the landline number of that line in though.

[from-trunk-LLBT2]
exten => _X!,1,set(CALLERID(number)=${REPLACE(CALLERID(number), ,)})
exten => _X!,n,set(CALLERID(number)=${REPLACE(CALLERID(number),-,)})
exten => _X!,n,noop(CALLERID is now ${CALLERID(all)})
exten => _X!,n,Goto(from-trunk,${EXTEN},1)
lgaetz commented 10 years ago

Just insert the one main line in the existing context like so:

[from-trunk-LLBT2]
exten => _X!,1,set(CALLERID(number)=${REPLACE(CALLERID(number), ,)})
exten => _X!,n,set(CALLERID(number)=${REPLACE(CALLERID(number),-,)})
exten => _X!,n,Set(CALLERID(number)=${IF($[ ${CALLERID(number)} = LLBT2]?00000:${CALLERID(number)})})
exten => _X!,n,noop(CALLERID is now ${CALLERID(all)})
exten => _X!,n,Goto(from-trunk,${EXTEN},1)
myozone commented 10 years ago

Head slap ! - of course, just not thinking, trying to do too many things at once.

Thank you - I'll give it a go.

myozone commented 10 years ago

Ah oh !, I think I've broken Superfecta. I no longer get an email of any incoming call as I did before. I can get it to work if I place a number in the debug section of SF. I think I may have messed up superfecta.agi some how !?. Can the 'original' be posted here ?

Here's a bit of the log around where SF gets called :-

[2014-02-14 12:01:39] VERBOSE[4466][C-00000009] pbx.c: -- Executing [s@from-trunk:5] Set("SIP/SG 01234567890-00000019", "CIDSFSCHEME=YmFzZV9EZWZhdWx0") in new stack
[2014-02-14 12:01:39] VERBOSE[4466][C-00000009] pbx.c: -- Executing [s@from-trunk:6] AGI("SIP/SG 01234567890-00000019", "/var/www/html/admin/modules/superfecta/agi/superfecta.agi") in new stack
[2014-02-14 12:01:39] VERBOSE[4467][C-00000009] app_mixmonitor.c: == Begin MixMonitor Recording SIP/SG 01234567890-00000019
[2014-02-14 12:01:39] VERBOSE[4466][C-00000009] res_agi.c: -- Launched AGI Script /var/www/html/admin/modules/superfecta/agi/superfecta.agi
[2014-02-14 12:01:39] VERBOSE[4466][C-00000009] res_agi.c: -- <SIP/SG 01234567890-00000019>AGI Script /var/www/html/admin/modules/superfecta/agi/superfecta.agi completed, returning 0
[2014-02-14 12:01:39] VERBOSE[4466][C-00000009] pbx.c: -- Executing [s@from-trunk:7] Set("SIP/SG 01234567890-00000019", "CALLERID(name)=") in new stack
lgaetz commented 10 years ago

All files are here in the repo, link to superfecta.agi: https://raw.github.com/POSSA/Caller-ID-Superfecta/release/2.11/agi/superfecta.agi

myozone commented 10 years ago

Thanks for that, didn't work though, Any ideas - please ?

lgaetz commented 10 years ago

Unless you can figure out the error, just reinstall Superfecta from scratch. Uninstall in Module Admin then at the CLI:

amportal a ma delete superfecta

Then reinstall from Module Admin again. Note that you will, of course, lose your code changes and configuration.

myozone commented 10 years ago

Yeah ! , that worked. Thank you, I've no idea what went wrong (what I did ?) This a example of altering something to 'improve' it - to end up totally mess it up. I'll make an image of the working FreePBX and also a backup. So IF (when) I mess it up again I can possibly restore it that way too!.

lgaetz commented 10 years ago

Not sure how you are editing files, but it is critical that AGI files have the unix style line breaks preserved. If you are using windows, don't use 'normal' text editors get notepad++.

myozone commented 10 years ago

Yes, That's what I use Notepad++. I'm always carful to make sure files like this stay as pure text files. Saying that I also used another machine to look at the files that was Wordpad I think. That could have mess up the formatting - but I don't remember saving it back again to FreePBX - no matter it's working again