Dialplan for calling skype: gtalk: msn: yahoo: etc..

Catalog of dial plans
Post Reply
mnipp
Posts: 192
Joined: Sat Oct 03, 2009 9:48 am
Location: NSW Australia

Dialplan for calling skype: gtalk: msn: yahoo: etc..

Post by mnipp » Mon Sep 26, 2011 10:04 am

Using this code, calls in these forms will be sent out through the correct gateway

7654321 phone numbers pass through to a phone number dialplan below this code
abc123 dials sipsorcery user abc123 on sipsorcery
sip:user@host or user@host or user&host dials out to user@host
skype:skypeuser calls skypeuser with skypeuser@skype.sipnet.ru
gtalk:user@gmail.com or gtalk:user&gmail.com to user_at_gmail.com@gtalk.gtalk2voip.com
msn:user@hotmail.com or msn:user&hotmail.com to user_at_hotmail.com@msn.gtalk2voip.com
yahoo:user@yahoo.com or yahoo:user&yahoo.com to user_at_yahoo.com@yahoo.gtalk2voip.com
aim:user@host.com or aim:user&host.com to user_at_host.com@aim.gtalk2voip.com
icq:user@host.com or icq:user&host.com to user_at_host.com@icq.gtalk2voip.com

if user@host does not work use user&host

http://gtalk2voip.com/faq.shtml

Code: Select all

# Start of dialplan
sys.Log("Call to #{req.URI.User}@#{req.URI.Host}")
toName = req.URI.User.to_s.gsub(/%(..)/){$1.hex.chr}; toHost = req.URI.Host.to_s
toNamearray = toName.split(':', 2);    toName = toNamearray[1] || toNamearray[0]
sys.Log("array:#{toNamearray[0]},#{toNamearray[1]}; toName:#{toName}  toHost:#{toHost}")

if toName =~ /@/
   toHostarray = toName.split('@', 2)    
            toHost = toHostarray[1]
            toName = toHostarray[0]
end
if toName =~ /&/
   toHostarray = toName.split('&', 2)    
            toHost = toHostarray[1]
            toName = toHostarray[0]
end
sys.Log("array:#{toNamearray[0]},#{toNamearray[1]}; toName:#{toName}  toHost:#{toHost}")


if !toNamearray[1] or toNamearray[0].downcase == 'sip'
  if sys.GetCanonicalDomain(toHost) == "sipsorcery.com"
     sys.Dial("#{toName}@local")                   if toName =~ /[a-zA-Z]/ # if dialled sipsorcery name not number
     sys.Respond(480, "failed calling #{toName}.") if toName =~ /[a-zA-Z]/ # A failed sip dial, quit dial plan
  else
     sys.Log("sip call to #{toName}@#{toHost}")
     sys.Dial("#{toName}@" << "#{toHost}".downcase) # dial full sip address entered 
     sys.Respond(480, "failed sip dial.")                      # A failed sip dial, quit dial plan
  end
else
  sys.Log("Calling gateway for #{toNamearray[0]}:#{toName}@#{toHost}")
  case toNamearray[0].downcase
    when 'gtalk' then sys.Dial "#{toName}_at_#{toHost}@gtalk.gtalk2voip.com"
    when 'msn'   then sys.Dial "#{toName}_at_#{toHost}@msn.gtalk2voip.com"
    when 'yahoo' then sys.Dial "#{toName}_at_#{toHost}@yahoo.gtalk2voip.com"
    when 'aim'   then sys.Dial "#{toName}_at_#{toHost}@aim.gtalk2voip.com"
    when 'icq'   then sys.Dial "#{toName}_at_#{toHost}@icq.gtalk2voip.com"
    when 'skype' then sys.Dial "#{toName}@skype.sipnet.ru"
  end
  sys.Respond(480, "failed call to #{toNamearray[0]}:#{toName}@#{toHost}")  #  quit dial plan
end
sys.Respond(480, "(#{req.URI.User}) is a failed SPEED-DIAL") if req.URI.User.to_s != toName

# end of sip dial. 

 sys.Log("Calling phone number:#{req.URI.User}")

# start of phone-number dialplan example the following

sys.Dial("provider1") # dial phone numbers with provider1
Last edited by mnipp on Sun Oct 02, 2011 7:25 am, edited 1 time in total.
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: Dialplan for calling skype: gtalk: msn: yahoo: etc..

Post by qubo » Thu Sep 29, 2011 6:15 pm

hi. this dialplan detect the gateway automatic ? I use your recommended skype dialplan. that works fine. but it has a speeddial. example 901 to dial echo123@skype

so I have a question I should use the same logic to put speeddials to the diferent gateway I will use ? ex. 901 123echo@skype.... 902 ant@hotmail 903 fer@yahoo..... or how you could do a speed dial to assign numbers to address ?

mnipp
Posts: 192
Joined: Sat Oct 03, 2009 9:48 am
Location: NSW Australia

Re: Dialplan for calling skype: gtalk: msn: yahoo: etc..

Post by mnipp » Fri Sep 30, 2011 9:31 am

You can add a speed-dial option to the start of the dialplan.

Code: Select all

   # Start of dialplan
sys.Log("Call to #{req.URI.User}@#{req.URI.Host}")
toName = req.URI.User.to_s.gsub(/%(..)/){$1.hex.chr}; toHost = req.URI.Host.to_s

case toName
  when '901' then toName = "skype:user"            # ring skype "user"
  when '902' then toName = "gtalk:user@gmail.com"  # ring gtalk "user@gmail.com"
  when '903' then toName = "user"                  # ring "user" on sipsorcery
  when '904' then toName = "user@host.com"         # ring "user" on host.com
end

toNamearray = toName.split(':', 2);    toName = toNamearray[1] || toNamearray[0]
sys.Log("array:#{toNamearray[0]},#{toNamearray[1]}; toName:#{toName}  toHost:#{toHost}")
But if you are using a phone that can only dial numbers you can just add to your skype example.
http://gtalk2voip.com/faq.shtml

Code: Select all

case req.URI.User.to_s

# speed-dial preset names skypename1, user@gmail.com with 901, 902 etc..
  when '901'
     sys.Dial "skypename1@skype.sipnet.ru"              # ring skype "skypename1"
     sys.Respond(480, "Failed skype call")
  when '902'
     sys.Dial "user_at_gmail.com@gtalk.gtalk2voip.com"  # ring gtalk "user@gmail.com"
     sys.Respond(480, "Failed gtalk call")
  when '903'
     sys.Dial "user@local"                              # ring "user" on sipsorcery
     sys.Respond(480, "Failed sipsorcery call")
  when '904'
     sys.Dial "user@host.com"                           # ring "user" on host.com
     sys.Respond(480, "Failed sip call")
end
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: Dialplan for calling skype: gtalk: msn: yahoo: etc..

Post by qubo » Fri Sep 30, 2011 5:21 pm

HI. I put this but dont work could you help in finding where the error is ?


here my dialplan
case req.URI.User.to_s

# speed-dial preset skype names skypename1, skypename2 with 901, 902 etc..
when '901'
sys.Dial "echo123@skype.sipnet.ru"
sys.Respond(480, "Failed skype call")
when '801'
sys.Dial "jcolix&gmail.com@gtalk.gtalk2voip.com" # ring gtalk "user@gmail.com"
sys.Respond(480, "Failed gtalk call")
when '802'
sys.Dial "antux&hotmail.com@msn.gtalk2voip.com" # ring gtalk "user@hotmail.com"
sys.Respond(480, "Failed msn call")
end
and this is the console
login as: inquba
inquba@sipsorcery.com's password:
Welcome jose
filter=>
basetype=console, ipaddress=*, user=, event=*, request=*, serveripaddress=*, server=*, regex=.*.
NATKeepAlive 17:20:31:988 sip1(1940): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.75.29:5060.
NATKeepAlive 17:20:32:004 sip1(1940): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.75.29:5080.
DialPlan 17:20:35:316 sip1(6264): New call from udp:187.133.75.29:5060 successfully authenticated by digest.
DialPlan 17:20:35:332 sip1(6264): Using dialplan Mexico2 for Out call to sip:802@sipsorcery.com.
NewCall 17:20:35:332 sip1(6264): Executing script dial plan for call to 802.
DialPlan 17:20:35:410 sip1(6264): Commencing Dial with: antua&hotmail.com@msn.gtalk2voip.com.
DialPlan 17:20:35:410 sip1(6264): Attempting to locate a provider for call leg: sip:802@antua.
DialPlan 17:20:35:410 sip1(6264): Attempting to locate a provider for call leg: sip:hotmail.com@msn.gtalk2voip.com.
DialPlan 17:20:35:410 sip1(6264): ForkCall commencing call leg to sip:802@antua.
DialPlan 17:20:35:410 sip1(6264): ForkCall commencing call leg to sip:hotmail.com@msn.gtalk2voip.com.
DialPlan 17:20:35:410 sip1(6264): Switching to sip:802@antua:5060 via udp:69.59.142.213:5060.
DialPlan 17:20:35:426 sip1(6264): Switching to sip:hotmail.com@msn.gtalk2voip.com:5060 via udp:69.59.142.213:5060.
DialPlan 17:20:35:426 sip1(6264): SDP on UAC call had public IP not mangled, RTP socket 187.133.75.29:13906.
DialPlan 17:20:35:426 sip1(6264): SDP on UAC call had public IP not mangled, RTP socket 187.133.75.29:13906.
DialPlan 17:20:35:426 sip1(6264): Information response 100 Trying for sip:hotmail.com@msn.gtalk2voip.com.
DialPlan 17:20:36:051 sip1(6264): Information response 183 Progress for sip:hotmail.com@msn.gtalk2voip.com.
DialPlan 17:20:36:051 sip1(6264): UAS call progressing with SessionProgress.
NATKeepAlive 17:20:37:051 sip1(1940): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:204.236.220.22:43231.
NATKeepAlive 17:20:37:066 sip1(1940): Requesting NAT keep-alive from proxy socket tcp:69.59.142.213:2060 to tcp:187.133.75.29:51775.
DialPlan 17:20:37:238 sip1(6264): Response 604 Host antua unresolvable for sip:802@antua.
NATKeepAlive 17:20:42:098 sip1(1940): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.75.29:5060.
NATKeepAlive 17:20:42:129 sip1(1940): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:187.133.75.29:5080.

basetype=console, ipaddress=*, user=, event=*, request=*, serveripaddress=*, server=*, regex=.*.
NATKeepAlive 17:20:47:160 sip1(1940): Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:204.236.220.22:43231.
NATKeepAlive 17:20:47:192 sip1(1940): Requesting NAT keep-alive from proxy socket tcp:69.59.142.213:2060 to tcp:187.133.75.29:51775.

mnipp
Posts: 192
Joined: Sat Oct 03, 2009 9:48 am
Location: NSW Australia

Re: Dialplan for calling skype: gtalk: msn: yahoo: etc..

Post by mnipp » Fri Sep 30, 2011 11:08 pm

Code: Select all

when '801'
    sys.Dial "jcolix&gmail.com@gtalk.gtalk2voip.com" # ring gtalk "jcolix@gmail.com"
    sys.Respond(480, "Failed gtalk call")
using the (&)symbol in a sys.Dial will divide the call into two destinations (801@jcolix)(gmail.com@gtalk.gtalk2voip.com) not what you want.

replace the (&) with (_at_) as shown http://gtalk2voip.com/faq.shtml to use their gateway.

Code: Select all

when '801'
   sys.Dial "jcolix_at_gmail.com@gtalk.gtalk2voip.com" # ring gtalk "jcolix@gmail.com"
   sys.Respond(480, "Failed gtalk call")
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)

qubo
Posts: 127
Joined: Tue Apr 12, 2011 6:11 am

Re: Dialplan for calling skype: gtalk: msn: yahoo: etc..

Post by qubo » Fri Sep 30, 2011 11:54 pm

thanks I thought when you put _at_ meaning @ that fixed the error. but it works with gtalk gmail account but with MSN it does not ring at all ? maybe the msn messanger need some special conf


thanks a lot

Post Reply