Skip to content

Instantly share code, notes, and snippets.

@freakeinstein
Created May 10, 2019 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freakeinstein/b4b8b8bf7c0962dda058821ab8c4830c to your computer and use it in GitHub Desktop.
Save freakeinstein/b4b8b8bf7c0962dda058821ab8c4830c to your computer and use it in GitHub Desktop.
hangout simple request response
#!/usr/bin/env python3
"""Example bot that returns a synchronous response."""
from flask import Flask, request, json
app = Flask(__name__)
@app.route('/', methods=['POST'])
def on_event():
"""Handles an event from Hangouts Chat."""
event = request.get_json()
if event['type'] == 'ADDED_TO_SPACE' and event['space']['type'] == 'ROOM':
text = 'Thanks for adding me to "%s"!' % event['space']['displayName']
elif event['type'] == 'MESSAGE':
text = 'You said: `%s`' % event['message']['text']
else:
return
return 'OK' #json.jsonify({'text': text})
if __name__ == '__main__':
app.run(port=4000, debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment