Page 1 of 1

Trying to divert an incoming call with dial plan

Posted: Tue Feb 05, 2013 4:24 pm
by agsteele
I have a couple of incoming numbers that I need to divert to null, or hangup on without ringing the ATA or even better diverting to on-hold music so that they get charged for the initial connection even if they then hang up.

I've taken a look at the Ruby dialplan that I have that works well for me and certainly don't want to break anything.

The incoming calls bit is currently very simple...

Code: Select all

  # Incoming Calls
  sys.Log("Incoming call to #{req.URI.User}.")

  # Call forwards.
 
end
What I want to do is allow all calls to be handled as at present except for those which have CallerID displayed with a specific format 008000nnnnnnn

Ideally I'd like to generate an Email alert that a call has been handled in this way so that I can monitor what is going on.

Sadly I'm finding the various bits of DialPlan documentation rather dense.

Anyone offer a pointer to the way forward?

Thanks in advance.

Andrew

Re: Trying to divert an incoming call with dial plan

Posted: Tue Feb 05, 2013 10:08 pm
by Aaron
Try this, ensuring to replace "youraccount" with the name of the SIP account you want to forward your incoming calls to and also enter your own email address:

Code: Select all

  # Incoming Calls
  sys.Log("Incoming call to #{req.URI.User}.")

  if req.Header.From.FromURI.User =~ /^008000/ 
    # Forward undesireables to music on hold.
    sys.SendEmail("your@emailaddress", "Blocked Call", "Call from #{req.Header.From.FromURI.User} was forwarded to MOH.")
    sys.Dial("music@iptel.org")
  else
    # Forward all other calls to your SIP account.
    sys.Dial("youraccount@local")
  end

Re: Trying to divert an incoming call with dial plan

Posted: Wed Feb 06, 2013 9:17 am
by agsteele
Thanks Aaron,

I'll give it a try...

Andrew

Re: Trying to divert an incoming call with dial plan

Posted: Tue Oct 29, 2013 2:32 am
by netvoice
Hi Aaron,

If I have several numbers need to forward to MOH, what should I write in the rule? I try to put numbers like

Code: Select all

 if req.Header.From.FromURI.User =~ /123456789/564213789/
 sys.Dial("music@iptel.org")
But it doesn't wrok.

Thanks