Skip to content

Instantly share code, notes, and snippets.

@mooose
Last active December 5, 2018 10:37
Show Gist options
  • Save mooose/aae0e7d8929f2dd529910e69005ffba7 to your computer and use it in GitHub Desktop.
Save mooose/aae0e7d8929f2dd529910e69005ffba7 to your computer and use it in GitHub Desktop.
Sending a simple message from python to Hangout Chat Group
WEBHOOK_URL = <URL of Hangout Chat Group to push a message to>
from google.appengine.api import urlfetch
import urllib
def hangoutAlert(message):
"""hangoutAlert
send a message to hangoutAlert via Hangout Chat Alerts Group
"""
bot_message = urllib.urlencode({'text' : message })
message_headers = { 'Content-Type': 'application/json; charset=UTF-8'}
urlfetch.fetch(url=WEBHOOK_URL, method=2, payload=bot_message, headers=message_headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment