text: #!/usr/bin/env python
  
  from __future__ import print_function
  from future import standard_library
  standard_library.install_aliases()
  import urllib.request, urllib.parse, urllib.error
  import json
  import os
  
  from flask import Flask
  from flask import request
  from flask import make_response
  
  # Flask app should start in global layout
  app = Flask(__name__)
  
  
  @app.route('/webhook', methods=['POST'])
  def webhook():
      req = request.get_json(silent=True, force=True)
  
      print("Request:")
      print(json.dumps(req, indent=4))
  
      res = processRequest(req)
  
      res = json.dumps(res, indent=4)
      # print(res)
      r = make_response(res)
      r.headers['Content-Type'] = 'application/json'
      return r
  
  
  def processRequest(req):
  	if req.get("result").get("action") == "Position":
  		speech = "https://www.google.es/search?q=mapa+barcelona&espv=2&biw=1366&bih=662&source=lnms&tbm=isch&sa=X&ved=0ahUKEwi_9c7pi-DRAhVH6GMKHbBOD4YQ_AUIBygC#imgrc=WEoA_MiNn50OpM%3A"
  		res = makeWebhookResult(speech)
  		return res
  	elif req.get("result").get("action") == "Expenses":
  		speech = "You has spent X Euros"
  		res = makeWebhookResult(speech)
  		return res
  	else:
  		return {}
  
  
  
  def makeWebhookResult(speech):
      print("Response:")
      print(speech)
  
      return {
          "speech": speech,
          "displayText": speech,
          # "data":[],
          # "contextOut": [],
          "source": "prueba"
      }
  
  
  if __name__ == '__main__':
      port = int(os.getenv('PORT', 5000))
  
      print("Starting app on port %d" % port)
  
      app.run(debug=False, port=port, host='0.0.0.0')
  