Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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']
return 'OK' #json.jsonify({'text': text})
if __name__ == '__main__':, debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment