Analog incoming zaptel lines. I am getting the caller ID, but the incoming route won't act on it

I have an incoming route that contains my wife’s cell phone number in the clid field. When she calls in she should get a menu that is different from the main menu.

On the asterisk CLI I see the call come in, and the CLID appears correctly, but the call just ends up in the main menu.

The thing is, I have routes that are assigned to the zap channels specifically, and I am wondering whether they take priority over this route.

So perhaps the question is: is there a way to rank the incoming routes? Should I just add the caller ID to one of those routes? What happens if I want to add more than one CLID routing entry?

TIA for any hints or tips.

Jim

This is a limitation of the current zap channel routing ability. If you choose to route by channel, it ignores both the did and cid field. You would have to make a custom context for the specific channel and then route it appropriately to get this to work. It will be addressed in a future implementation but for now this is the limitation.

Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx

Fair enough. Thanks for the reply.

Would you like to try the following patch. I think it will enable zapchannel/cid routing but don’t have a system here to test it on:

this patch should be applied to /var/www/html/admin/modules/core/functions.inc.php

Index: functions.inc.php
===================================================================
--- functions.inc.php (revision 5170)
+++ functions.inc.php (working copy)
@@ -180,15 +180,16 @@
          $exten = (empty($exten)?"s":$exten);
          $exten = $exten.(empty($cidnum)?"":"/".$cidnum); //if a CID num is defined, add it

-         if (empty($channel))
            $context = "ext-did";
-         else {
-           $context = "macro-from-zaptel-{$channel}";
+         if (!empty($channel)) {
+           $zap_context = "macro-from-zaptel-{$channel}";
+           $exten = 'chan'.$channel.(empty($cidnum)?"":"/".$cidnum); //if a CID num is defined, add it
            if (!isset($zapchan[$channel])) {
              // create the macro-from-zaptel-$chan context and load up the
              // startup settings
-             $ext->add($context, 'fax', '', new ext_goto('1','in_fax','ext-fax'));
-             $ext->add($context, 's', '', new ext_noop('Entering '.$context.' with DID = ${DID}'));
+             $ext->add($zap_context, 'fax', '', new ext_goto('1','in_fax','ext-fax'));
+             $ext->add($zap_context, 's', '', new ext_noop('Entering '.$context.' with DID = ${DID}'));
+             $ext->add($zap_context, 's', '', new ext_goto('1','chan'.$channel,$context));
              $zapchan[$channel] = "unfinished";

this patch should be applied to /var/www/html/admin/modules/core/page.did.php

--- page.did.php  2007-08-20 21:41:03.000000000 -0700
+++ /var/www/html/admin/modules/core/page.did.php 2007-11-02 10:43:05.000000000 -0700
@@ -266,7 +266,7 @@
 function editGRP_onsubmit() {
  var msgInvalidDIDNumb = "<?php echo _('Please enter a valid DID Number'); ?>";
  var msgInvalidCIDNum = "<?php echo _('Please enter a valid Caller ID Number'); ?>";
- var msgCidDidWithZaptel = "<?php echo _('DID number and CID number MUST be blank when used with zaptel channel routing'); ?>";
+ var msgCidDidWithZaptel = "<?php echo _('DID number MUST be blank when used with zaptel channel routing'); ?>";
  var msgInvalidFaxEmail = "<?php echo _('Please enter a valid Fax Email or leave it empty to use the default'); ?>";
  var msgInvalidPause = "<?php echo _('Please enter a valid number for Pause after answer'); ?>";
  var msgConfirmDIDCIDBlank = "<?php echo _('Leaving the DID Number AND the Caller ID Number empty will match all incoming calls received not routed using any other defined
 Incoming Route.\n\nAre you sure?'); ?>";
@@ -302,9 +302,9 @@
  if (theForm.extension.value != ""  && theForm.channel.value != "" ) {
    return warnInvalid(theForm.extension, msgCidDidWithZaptel);
  }
- if (theForm.cidnum.value != ""  && theForm.channel.value != "" ) {
-   return warnInvalid(theForm.cidnum, msgCidDidWithZaptel);
- }
+ //if (theForm.cidnum.value != ""  && theForm.channel.value != "" ) {
+   //return warnInvalid(theForm.cidnum, msgCidDidWithZaptel);
+ //}
  // warning about 'any DID / any CID'
  if (theForm.extension.value == "" && theForm.cidnum.value == "" && theForm.channel.value == "" ) {
    if (!confirm(msgConfirmDIDCIDBlank))

As always, make backups of these two files first.


Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx

I tried running patch on those.

With
patch functions.inc.php functions.inc.php.PATCH
I got the following :
Hunk #1 FAILED at 180.

With
patch page.did.php page.did.php.PATCH

I got:
patching file page.did.php
Hunk #1 FAILED at 266.
1 out of 1 hunk FAILED – saving rejects to file page.did.php.rej
missing header for unified diff at line 13 of patch
can’t find file to patch at input line 13
Perhaps you should have used the -p or --strip option?
The text leading up to this was:

Incoming Route.\n\nAre you sure?’); ?>";

File to patch:

I’m not very experienced with the patch command, so it could be that I was using it wrong. I saved these to files and ran
patch destinationfile patchfile

Jim

Jim,
I emailed them to you in case you were having problems copying them from here.

Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx

OK, I put the patches in and implemented, but did not get the results I wanted.

Here is some code from the dialplan. I think the problem is that the [ext-did] context does not have an include=> in the [from-zaptel] context (which is where the call enters the dialplan).

[ext-did]
include => ext-did-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s/6478965963,1,Set(__FROM_DID=${EXTEN})
exten => s/6478965963,n,Gosub(app-blacklist-check,s,1)
exten => s/6478965963,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => s/6478965963,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s/6478965963,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s/6478965963,n,Goto(ivr-3,s,1)
[from-zaptel]
exten => _X.,1,Set(DID=${EXTEN})
exten => _X.,n,Goto(s,1)
exten => s,1,NoOp(Entering from-zaptel with DID == ${DID})
; Some trunks _require_ a RINGING be sent before an Answer.
exten => s,n,Ringing()
; If ($did == "") { $did = "s"; }
exten => s,n,Set(DID=${IF($["${DID}"= ""]?s:${DID})})
exten => s,n,NoOp(DID is now ${DID})
exten => s,n,GotoIf($["${CHANNEL:0:3}"="Zap"]?zapok:notzap)
exten => s,n(notzap),Goto(from-pstn,${DID},1)
; If there's no ext-did,s,1, that means there's not a no did/no cid route. Hangup.
exten => s,n,Macro(hangup)
exten => s,n(zapok),NoOp(Is a Zaptel Channel)
exten => s,n,Set(CHAN=${CHANNEL:4})
exten => s,n,Set(CHAN=${CUT(CHAN,-,1)})
exten => s,n,Macro(from-zaptel-${CHAN},${DID},1)
; If nothing there, then treat it as a DID
exten => s,n,NoOp(Returned from Macro from-zaptel-${CHAN})
exten => s,n,Goto(from-pstn,${DID},1)
exten => fax,1,Goto(ext-fax,in_fax,1)

patch did not apply or something else is up. In extenions_additional.conf you should see one context that looks like this (in this case channel 1) - note, mine may be a little different, I’ve been tweaking some of this. In this case there are three routes to channel 1, with no cid, with 222 and with 225.

[macro-from-zaptel-1]
include => macro-from-zaptel-1-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Noop(Entering ext-did with DID = ${DID})
exten => s,n,Goto(ext-did,chan1,1)

; end of [macro-from-zaptel-1]

and then ext-did should have some contexts that look like this (only putting in part of mine):

[ext-did]
include => ext-did-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=${EXTEN})
exten => s,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => s,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s,n,Set(FAX_RX=system)
exten => s,n,Set([email protected])
exten => s,n,Answer
exten => s,n,Playtones(ring)
exten => s,n,NVFaxDetect(5)
exten => s,n,Goto(ivr-1,s,1)
exten => chan1,1,Set(__FROM_DID=${DID})
exten => chan1,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => chan1,n,Set(CALLERID(name)=${CALLERID(num)})
exten => chan1,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => chan1,n,Macro(privacy-mgr,)
exten => chan1,n,Set(_RGPREFIX=Z:)
exten => chan1,n,Set(CALLERID(name)=${RGPREFIX}${CALLERID(name)})
exten => chan1,n,Goto(from-did-direct,222,1)
exten => chan1/222,1,Set(__FROM_DID=${DID})
exten => chan1/222,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => chan1/222,n,Set(CALLERID(name)=${CALLERID(num)})                                                                                                 
exten => chan1/222,n(cidok),Noop(CallerID is ${CALLERID(all)})                                                                                            
exten => chan1/222,n,Goto(ext-group,1,1)                                                                                                                  
exten => chan1/225,1,Set(__FROM_DID=${DID})                                                                                                               
exten => chan1/225,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)                                                                                        
exten => chan1/225,n,Set(CALLERID(name)=${CALLERID(num)})                                                                                                 
exten => chan1/225,n(cidok),Noop(CallerID is ${CALLERID(all)})                                                                                            
exten => chan1/225,n,Goto(from-did-direct,212,1)

Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx

[macro-from-zaptel-1]
include => macro-from-zaptel-1-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Noop(Entering macro-from-zaptel-1 with DID = ${DID})
exten => s,n,Gosub(app-blacklist-check,s,1)
exten => s,n,Set(__FROM_DID=${EXTEN})
exten => s,n,GotoIf($[ "${CALLERID(name)}" != "" ] ?cidok)
exten => s,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s,n,Goto(ivr-2,s,1)

Jim,
the patch is not applying or you would get the changes. Or, something else broke and no new files are being executed. You can go to /var/lib/asterisk/bin and then su to user asterisk and execute retrieve_conf and see if you are getting any errors (which would normally get displayed if you were during an update but ?)

Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx