Created
February 18, 2022 11:05
-
-
Save imtrinity94/3d0b0f9e62fb26695723be53662a891a to your computer and use it in GitHub Desktop.
Hangouts Chat incoming webhook quickstart.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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