Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Code for Good

Code for Good

Code is not only for making money. Code can actually help people!

Benedikt Deicke

July 08, 2013
Tweet

More Decks by Benedikt Deicke

Other Decks in Technology

Transcript

  1. € € € € €     €

    € € € €     € € € € €    
  2.          

                                  “Cellphone companies say service is operating in the Boston area, but with heavy traffic following of the explosions at the Boston Marathon.” – Associated Press
  3. 25,000 unique visitors 967 outbound calls 1353 minutes (1,500 from

    Boston metro area) 2510 Retweets 1432 Likes
  4. import os import signal from flask import Flask from flask

    import render_template from flask import url_for from flask import request from twilio import twiml from twilio.util import TwilioCapability # Declare and configure application app = Flask(__name__, static_url_path='/static') app.config.from_pyfile('local_settings.py') @app.route('/', methods=['GET', 'POST']) def index(): # Make sure we have this host configured properly. config_errors = [] for option in ['TWILIO_ACCOUNT_SID', 'TWILIO_AUTH_TOKEN']: if not app.config[option]: config_errors.append("%s is not configured for this host." % option) # Define important links params = { 'sms_request_url': url_for('.sms', _external=True), 'config_errors': config_errors} # Generate capability token capability = TwilioCapability(app.config['TWILIO_ACCOUNT_SID'], app.config['TWILIO_AUTH_TOKEN']) capability.allow_client_outgoing(app.config['TWILIO_APP_SID']) token = capability.generate() # If not a submission, render form. return render_template('index.html', params=params, token=token) @app.route('/voice', methods=['POST']) def voice(): response = twiml.Response() with response.dial(callerId=app.config['TWILIO_CALLER_ID'], timeLimit="600") as dial: dial.number(request.form['PhoneNumber']) return str(response) @app.route('/inbound', methods=['POST']) def inbound(): response = twiml.Response() response.play('/static/sounds/inbound.mp3') return str(response) @app.route('/sms', methods=['GET', 'POST']) def sms(): # Respond to any text inbound text message with a link to the app! response = twiml.Response() response.sms("This number belongs to the Twilio Call Your Family app " \ "for Boston. Please visit " \ "http://callyourfamily.twilio.ly for more info.") return str(response) # Handles SIGTERM so that we don't get an error when Heroku wants or needs to # restart the dyno def graceful_shutdown(signum, frame): exit() signal.signal(signal.SIGTERM, graceful_shutdown) if __name__ == '__main__': port = int(os.environ.get("PORT", 5000)) if port == 5000: app.debug = True app.run(host='0.0.0.0', port=port) 81 Lines of Code Outbound Calls via Web Inbound Call Response Inbound SMS Response
  5. Organization Registry Project Tracking Human Resources Inventory Assets Assessments Shelter

    Management Scenarios & Events Mapping Messaging Sahana Eden
  6. Wildfires, Chile – 2012 Earthquake & Tsunami, Japan – 2011

    Flooding, Colombia – 2011 Flooding, Venezuela – 2010 Flooding, Pakistan – 2010 Hurricane, Mexico – 2010 Eden Deployments Photo credit: NASA
  7. “In that moment I had what can only be described

    as an epiphany. If I could somehow connect this woman with my friends and family back home, she would have the money to pay for her son’s medical treatment within the day.” Chase Adam