Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save imtrinity94/3d0b0f9e62fb26695723be53662a891a to your computer and use it in GitHub Desktop.
Save imtrinity94/3d0b0f9e62fb26695723be53662a891a to your computer and use it in GitHub Desktop.
Hangouts Chat incoming webhook quickstart.py
from json import dumps
from httplib2 import Http
def main():
"""Hangouts Chat incoming webhook quickstart."""
url = '<INCOMING-WEBHOOK-URL>'
bot_message = {
'text' : 'Hello from a Python script!'}
message_headers = {'Content-Type': 'application/json; charset=UTF-8'}
http_obj = Http()
response = http_obj.request(
uri=url,
method='POST',
headers=message_headers,
body=dumps(bot_message),
)
print(response)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment