Skip to content

Instantly share code, notes, and snippets.

Embed
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']
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