19

If someone adds bot@mydomain.com to his Google Hangout contacts and sends it a Google+ Hangout Chat message, I want to set up an automatic reply to his chat from my server. Is there a way to do that??

I think Its possible using the Google+ Hangouts API but I cannot figure out how.

(mydomain.com uses Google Apps for Business)

Gaurav Gupta
  • 5,380
  • 2
  • 29
  • 36
prateekkathal
  • 3,482
  • 1
  • 20
  • 40

1 Answers1

4

Here's what you're looking: https://developers.google.com/+/hangouts/api/gapi.hangout.data

Here's the event for message recieved: (callback) https://developers.google.com/+/hangouts/api/gapi.hangout.data#gapi.hangout.data.onMessageReceived

And here's the event for sending the message: https://developers.google.com/+/hangouts/api/gapi.hangout.data#gapi.hangout.data.sendMessage

Michael Mikhjian
  • 2,760
  • 4
  • 36
  • 51
  • Isn't this only for Hangouts created using a Google+ Hangout Button on your own website? I want to make something like a bot. Like whenever a msg is received from any hangout to my bots account,it replies back with a specific message. – prateekkathal Apr 05 '14 at 16:34
  • @kakashihatake2 this would be a G+ app, so a user would have to add and accept your app, otherwise yeah you'd need to write a custom Jabber api. – Michael Mikhjian Apr 05 '14 at 16:35
  • Ummmm.... But how will I make the Google Hangout remember this forever, How will I make my user communicate with only and only my bot? Lets say he uses Google Hangout from his phone, then how will he communicate with my bot? – prateekkathal Apr 05 '14 at 17:04
  • So this document is about your app's running state @ https://developers.google.com/+/hangouts/running. Essentially your app would be a JS application, from JS you can pass data between the browser and your server side end. However, I think you're really looking for a Jabber hack here, i.e. if you plan on setting up a new google account so you can literally see a client, then yeah you want to go the custom Jabber route (aka connect google's chat server). – Michael Mikhjian Apr 05 '14 at 17:36
  • 3
    Hangouts doesn't support XMPP/Jabber. Talk did, but Hangouts doesn't. – jobukkit Dec 03 '14 at 19:45
  • @JopVernooij that's correct, thanks for pointing that out. Hangouts doesn't support xmpp/jabber, I don't think it even supports Websocket. However, my answer above is still correct as it corresponds with the official documentation provided by Google. – Michael Mikhjian Dec 03 '14 at 19:47
  • @JopV. correction - it does, but you have to enable "insecure apps" on your google account. I'm using Pidgin with Hangouts through XMPP right now. – klh Aug 03 '15 at 20:54