New GTalk Dial Plan Method

Latest news about SIP Sorcery
Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

New GTalk Dial Plan Method

Post by Aaron » Sat Aug 16, 2008 4:39 am

From the dial plan reference:

sys.GTalk(string username, string password, string sendToUser, string message) - Attempts to send a message to a gTalk user. The username and password must belong to a valid gTalk user and should be entered without @gmail.com or any other host portion. The sendToUser is the gTalk username of the account to send the message to (can be the same as username) also without the @gtalk.com or any other host portion. The message is the text that will be attempted to be sent.

Code: Select all

#Ruby dialplan example for sys.GTalk.
sys.GTalk("joe.bloggs", "password", "jane.doe", "Hello World!")
sys.GTalk("joe.bloggs", "password", "jane.doe", "#{req.URI.User}")
Note that at times it can take quite a while to establish a connection to the gTalk network and the sipswitch dialplan will only wait for a maximum of 5s. In the very limited testing undertaken so far the first attempt to send a message wil often timeout but subsequent ones will then work.

Regards,

Aaron

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Post by MikeTelis » Mon Aug 18, 2008 5:22 am

Aaron,

it didn't work :( I have this code in the very beginning of my dialplan:

Code: Select all

sys.Log("** Call from #{req.Header.From.ToString()} to #{req.URI.User} **")
result=sys.GTalk("mtelis","password","mtelis","** Call from #{req.Header.From.ToString()} to #{req.URI.User} **")
sys.Log("Gtalk result = '#{result}'")
(I tried this "result" thing when a mere call to sys.GTalk produced no effect... I though I might find something interesting there)

So, the following appeared on the Monitoring screen:

Code: Select all

06:14:30:184: Outgoing call to sip:303@sip.mysipswitch.com;transport=udp for mtelis@sip.mysipswitch.com. 
06:14:30:297: Outgoing call to sip:303@sip.mysipswitch.com;transport=udp for mtelis@sip.mysipswitch.com. 
06:14:30:568: ** Call from "Mike Telis" <sip:mtelis@sip.mysipswitch.com>;tag=35412a58 to 303 ** 
06:14:30:570: Attempting to connect to gTalk for mtelis. 
06:14:31:009: Connected to gTalk for mtelis@gmail.com. 
06:14:32:008: Gtalk result = ''
So far so good but however, I never received ANY message(s) on my GTalk. I repeated the experiment 5 to 10 times, so it's not the "first registration failed" thing.

I also tried sending messages to my friend's GTalk -- no luck. Thus, it's not "sending messages to myself" issue, either.

sudeepdennis
Posts: 43
Joined: Mon Sep 24, 2007 4:40 pm
Location: bangalore, india

Post by sudeepdennis » Mon Aug 18, 2008 7:44 am

Hi Mike,

I had a similar problem for sending from Gmail1 to Gmail2.
But then i opened Gmail2's google talk and sent an invitation to Gmail1 and then everything started worked fine.

Hi Aaron,

Thanks for this service. I am using it to keep a record of all the calls made using my gmail chat history(it is rather cumbersome to do this from the trace emails). It is worked excellently.

Is it possible to do something similar with gmail. Reason is that i cannot auto-forward gmail chat transcript to another email. My proposed usage is to send a mail to myself whenever someone is not able to complete a call in my dial plan(when the pstn gateway is not responding, to be particular). If we have a similar format for sending gmail, i can put it in the dial plan so that a mail will be sent to my mobile's SMS gateway, and will be recieved as an SMS. Maybe you can add this if you think it will be useful for others too.

Rgds,
Sudeep

hkr
Posts: 72
Joined: Sat Dec 15, 2007 10:05 am

Post by hkr » Mon Aug 18, 2008 8:16 am

sudeepdennis wrote: Is it possible to do something similar with gmail. Reason is that i cannot auto-forward gmail chat transcript to another email. My proposed usage is to send a mail to myself whenever someone is not able to complete a call in my dial plan(when the pstn gateway is not responding, to be particular). If we have a similar format for sending gmail, i can put it in the dial plan so that a mail will be sent to my mobile's SMS gateway, and will be recieved as an SMS. Maybe you can add this if you think it will be useful for others too.
Yesssss. An e-mail function would really be useful.

sys.email(toaddress,subject,body)

Sender/sender email should be the registered e-mail address of the account holder.


The other thing I have thought of is calling URL's... Betamax has nice SMS features available via URLs for example.

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Post by MikeTelis » Mon Aug 18, 2008 8:46 am

I had a similar problem for sending from Gmail1 to Gmail2.
But then i opened Gmail2's google talk and sent an invitation to Gmail1 and then everything started worked fine.
Your workaround really works, thank you! Did you figure out how to send messages to your own GTalk?

sudeepdennis
Posts: 43
Joined: Mon Sep 24, 2007 4:40 pm
Location: bangalore, india

Post by sudeepdennis » Mon Aug 18, 2008 9:22 am

Hi Mike,

I think I was wrong.

I am missing all the call details from around 0530 to 0900 GMT in my chat transcripts. I guess you might have been trying during this time.

By the way, calling to my own gtalk id had worked first shot itself.(I had tried it yesterday)

Rgds,
Sudeep

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Post by MikeTelis » Mon Aug 18, 2008 9:44 am

sudeepdennis,

I guess that Aaron's debugging this new GTalk code as we're trying to use it and vividly discussing why it doesn't work :) I will probably leave it alone for a while and try again when the dust settles down :lol:

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Mon Aug 18, 2008 9:59 am

There is no debugging of the gTalk code going on.

I'm not an expert in XMPP or gTalk.

The library used to provide the gTalk hook is http://www.ag-software.de/index.php?page=agsxmpp-sdk. The code used in mysipswitch to connect to gTalk is:

Code: Select all

 XmppClientConnection xmppCon = new XmppClientConnection();
xmppCon.Password = password;
xmppCon.Username = username;
xmppCon.Server = "gmail.com"; 
xmppCon.ConnectServer = "talk.google.com";
xmppCon.AutoAgents = false;
xmppCon.AutoPresence = false;
xmppCon.AutoRoster = false;
xmppCon.AutoResolveConnectServer = true;
xmppCon.Send(new Message(new Jid(sendToUser + "@gmail.com"), MessageType.chat, message));
Now you know as much about it as I do.

If you find a way to make it more reliable for your messages feel free to let me know and I can try it out (testing with my own gTalk accounts seemed to work pretty well).

Otherwise it's the same as everything else around here and is an experimental feature provided "as is".

Regards,

Aaron

User avatar
rmclaren
Posts: 68
Joined: Sun Feb 17, 2008 10:28 pm
Location: Connecticut

Post by rmclaren » Mon Aug 18, 2008 11:15 am

And another Asterisk function falls by the wayside! Now, there's one less reason to interface with Asterisk, if MySIPSwitch can handle GTalk. If only Skype were more open, we could probably handle it as well.

Although GTalk is way less popular than Skype, there are countries that block Skype (and probably other VOIP services), but allow GTalk traffic: Botswana, for instance.

sudeepdennis
Posts: 43
Joined: Mon Sep 24, 2007 4:40 pm
Location: bangalore, india

Post by sudeepdennis » Mon Aug 18, 2008 4:58 pm

Hi Aaron,

Could you make the sendToUser not restricted to gmail.com.

Since nokia chat also uses XMPP, i should be able to receive the messages on my mobile if it the messages are send to myaccount@ovi.com (nokia chat address). I am able to send messages from my Google talk to my Nokia Chat.

By removing the restriction on the destination address, I guess people would be able to send messages to any XMPP client of thier choice.

Rgds,
Sudeep

Post Reply