Outbound Dial Plan for MagicJack Users

Getting started with the SIP Sorcery

Outbound Dial Plan for MagicJack Users

Postby richardtaur » Mon Jul 13, 2009 9:29 pm

This is a simple outbound call for Magic Jack users. Make sure you will register your MagicJack SIP provider before you make phone calls.

Code: Select all
#Ruby
sys.Trace = true
sys.Log("*****************************************************\t")
sys.Log("*   MAGICJACK    OUTBOUND CALL FROM RUBY DIALPLAN   *\t")
sys.Log("*****************************************************\t")
sys.Log(" Received-URI:#{req.URI.User}\t URI-Length:#{req.URI.User.Length}\t")
sys.Log(" URI-Host:#{req.URI.Host}\t")
sys.Log(" From:#{req.Header.From.FromURI.User}\t\t Name:#{req.Header.From.FromName}\t")
sys.Log(" Incoming-Call:#{sys.In().ToString()}\t Outgoing-Call:#{sys.Out().ToString()}\t")
sys.Log(" ATA-Online:#{sys.IsAvailable("your_ss_username", "sipsorcery.com").ToString()}\t")   #put your SS user name.

# Logic for routing outgoing calls.
dialer = req.URI.User
case dialer
  when /^911/
    sys.Log(" Dialing #{req.URI.User} for emergencey.\t")
    sys.Log("*****************************************************\n")
    sys.Dial("MagicJack")
  when /^411/
    sys.Log(" Dialing #{req.URI.User} for Directory via MagicJack.\t")
    sys.Log("*****************************************************\n")
    sys.Dial("MagicJack")
  else
    case dialer
      when /^phone1|phone2/
        sys.Log(" Rejecting call to #{dialer}\t")
        sys.Log("*****************************************************\n")
        sys.Respond(488, "Your call is not welcome")
      else
        dialer_length = req.URI.User.Length.to_s
        case dialer_length
          when /^7/
            sys.Log(" Phone Call to xxx#{dialer} through MagicJack service.\t")     #Replace xxx to your area code.
            sys.Log("*****************************************************\n")
            sys.Dial("xxx${dst}@MagicJack")                    #Replace xxx to your area code.
          when /^10|11/
            sys.Log(" Phone Call to #{dialer} through MagicJack service.\t")
            sys.Log("*****************************************************\n")
            sys.Dial("MagicJack")
          else
            sys.Log(" Call Result: No dial plan match.\t")
            sys.Log("*****************************************************\n")
            sys.Respond(404, "No dial plan match")
        end
    end
end


For the inbound, I am having all kind of problems to receive incoming calls. I will suggest you to leave blank for the In Dial Plan, and make Out Dial Plan for the outbound call dial plan.
richardtaur
 
Posts: 109
Joined: Wed Apr 09, 2008 4:13 pm

Re: Outbound Dial Plan for MagicJack Users

Postby stav » Fri Aug 14, 2009 4:28 pm

richardtaur wrote:This is a simple outbound call for Magic Jack users. Make sure you will register your MagicJack SIP provider before you make phone calls.

Code: Select all
#Ruby
sys.Trace = true
sys.Log("*****************************************************\t")
sys.Log("*   MAGICJACK    OUTBOUND CALL FROM RUBY DIALPLAN   *\t")
sys.Log("*****************************************************\t")
sys.Log(" Received-URI:#{req.URI.User}\t URI-Length:#{req.URI.User.Length}\t")
sys.Log(" URI-Host:#{req.URI.Host}\t")
sys.Log(" From:#{req.Header.From.FromURI.User}\t\t Name:#{req.Header.From.FromName}\t")
sys.Log(" Incoming-Call:#{sys.In().ToString()}\t Outgoing-Call:#{sys.Out().ToString()}\t")
sys.Log(" ATA-Online:#{sys.IsAvailable("your_ss_username", "sipsorcery.com").ToString()}\t")   #put your SS user name.

# Logic for routing outgoing calls.
dialer = req.URI.User
case dialer
  when /^911/
    sys.Log(" Dialing #{req.URI.User} for emergencey.\t")
    sys.Log("*****************************************************\n")
    sys.Dial("MagicJack")
  when /^411/
    sys.Log(" Dialing #{req.URI.User} for Directory via MagicJack.\t")
    sys.Log("*****************************************************\n")
    sys.Dial("MagicJack")
  else
    case dialer
      when /^phone1|phone2/
        sys.Log(" Rejecting call to #{dialer}\t")
        sys.Log("*****************************************************\n")
        sys.Respond(488, "Your call is not welcome")
      else
        dialer_length = req.URI.User.Length.to_s
        case dialer_length
          when /^7/
            sys.Log(" Phone Call to xxx#{dialer} through MagicJack service.\t")     #Replace xxx to your area code.
            sys.Log("*****************************************************\n")
            sys.Dial("xxx${dst}@MagicJack")                    #Replace xxx to your area code.
          when /^10|11/
            sys.Log(" Phone Call to #{dialer} through MagicJack service.\t")
            sys.Log("*****************************************************\n")
            sys.Dial("MagicJack")
          else
            sys.Log(" Call Result: No dial plan match.\t")
            sys.Log("*****************************************************\n")
            sys.Respond(404, "No dial plan match")
        end
    end
end


For the inbound, I am having all kind of problems to receive incoming calls. I will suggest you to leave blank for the In Dial Plan, and make Out Dial Plan for the outbound call dial plan.


Trying to run MJ with SS still a lot of troubles, but one thing I noticed is that under CDR, all my outbound numbers have 1311 in front of the area code. Any explanation? How to get rid of this?
Thanks
stav
 
Posts: 1
Joined: Fri Aug 14, 2009 4:20 pm

Postby richardtaur » Sat Aug 15, 2009 2:55 am

The reason is because MJ blocks the traffic coming from SS, therefore; MJ won't work with SS any more.
richardtaur
 
Posts: 109
Joined: Wed Apr 09, 2008 4:13 pm


Return to Getting Started

Who is online

Users browsing this forum: No registered users and 0 guests