twilio and parse: rich experiences in & out of native clients

23
Thomas Bouldin @inilned Twilio and Parse Rich Experiences in & out of Native Clients

Upload: thomas-bouldin

Post on 16-Jul-2015

193 views

Category:

Software


2 download

TRANSCRIPT

Thomas Bouldin

@inilned

Twilio and ParseRich Experiences in & out of Native Clients

What is an App?

Think outside the 4” box

Modern apps are in the cloud

The cloud has no home button

The cloud never sleeps

The cloud is complicated

Your App Here

What is Parse?

Data Social Push

AnalyticsHostingCloud Code

Parse is Everywhere

Twilio + Parse

Cross platform clouds are awesome

Cross-media clouds are awesomer

Twilio provides reach, delivery, and events

Parse provides persistence, logic, and native

apps

SMS or App

Apps have a custom experience

Apps are bespoke

Apps have high acquisition costs

SMS is universal

SMS is far reaching

SMS is guaranteed

Four different ways

SMS or App

Exclusive SMS is the App

Hybrid Apps require SMS for core features

Parity SMS or App are portals to the same

experience

Segmentation Different roles have different

environments

AnyQs: A Twilio + Parse app to handle Q&A

Building a Segmented App

A quick afternoon hack on Twilio + Parse

Audience members ask questions via SMS

Web app allows moderators to approve or reject

Native app for presenter to review questions

Data Model

Pending

Class Structure State Machine

RejectedAccepted

Answered

Question

to: string

from: string

prompt: string

state: string

Cloud Code in Depth

Data HostingCloud Modules

Functions Background Jobs

Asking Questions

How is

babby

formed

?

Get a Parse Sub-Domain (opt)

Asking Questions

Within your Parse App’s settings

Tell Twilio Where to Send Messages

Asking Questions

Within the settings of your Twilio number:

Set up Twilio and Express

Asking Questions

var twilio = require("twilio");

twilio.initialize(account SID, auth token);

var Question = Parse.Object.extend("Question");

var express = require("express");

var app = express();

app.use(express.bodyParser);

app.listen();

app.post("/questions", function(request, response) {

// TODO: stuff... (next slide)

});

Implementing /questions

Asking Questions

var question = new Question({

from: request.body.From,

to: request.body.To,

status: "pending",

prompt: request.body.Body

});

question.save().then(function() {

response.send("");

}, function(error) {

response.status(500);

response.send(error);

});

Moderating Questions

Simple Web App UI

Moderating Questions

Get Pending Questions

Moderating Questions

var Question = Parse.Object.extend("Question");

var query = new Parse.Query(Question);

query.equalTo("status", "pending");

query.find().then(function(results) {

table.empty();

_.each(results, function(question) {

addRow(question.id, question.get("prompt"));

});

});

Modifying Questions

Moderating Questions

function updateQuestion(id, status) {

}

var row = $("#question" + id);

row.children("button").attr("disabled", "disabled");

var question = new Question();

question.id = id;

question.set("status", status);

question.save().then(function() {

row.remove();

});

Responding to Users

Moderating Questions

Parse.Cloud.beforeSave("Question", function(req, resp) {

var q = request.object;

var promise = Parse.Promise.as(); // already fulfilled

if (q.dirty("status") &&

q.get("status") === "rejected") {

promise = twilio.sendSMS({

From: q.get("to"),

To: q.get("from"),

Body: "Being off topic makes me a sad panda."

});

}

promise.then(function() { resp.success(); },

function(error) { resp.error(error) });

});

Answering Questions

Thomas Bouldin

@inilned

Concluding with a DemoAKA Q&A

Hack Ideas

Push + SMS chatroom

SMS password reset

SMS alerts on data streams

SMS voting + Parse Analytics