Find file
Fetching contributors…
Cannot retrieve contributors at this time
95 lines (83 sloc) 2.65 KB
<!doctype html>
<title>Twilio Chat</title>
<!-- JS dependencies - jQuery is not required, but included to make DOM manipulation and Ajax easier -->
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
<script src="//"></script>
<!-- A bit of style -->
<link rel="stylesheet" href="/style.css" type="text/css" media="screen" title="no title" charset="utf-8"/>
<!-- Just going to inline our app logic - that's cool with you, right? -->
<script type="text/javascript" charset="utf-8">
//handle incoming chat messages, pushed by App Engine
function onMessage(message) {
var current = $('textarea').val();
message && $('textarea').val(current + '\n' +;
//Initialize our little chat application
$(function() {
//Get a client token to use with the channel API
success: function(token) {
var channel = new goog.appengine.Channel(token);
var socket =;
//Assign our handler function to the open socket
socket.onmessage = onMessage;
//handle submitting chat message
function submitMessage() {
$.ajax('/chat', {
data: {
success:function(response) {
//Attach event handlers
$('button').on('click', submitMessage);
$('input').keypress(function (e) {
if (e.which == 13) {
<div id="container">
<div id="header">
<h1 class="section-heading">App Engine Chat</h1>
<div id="content">
<h2 class="section-heading">Chat via this web page, SMS, or XMPP (Google Talk).</h2>
<h4>To chat via SMS, send a text message to (text STOP to unsubscribe):</h4>
<div class="contact">+1 612-294-8105</div>
<h4>To chat via XMPP/Google Talk, send a message to (message STOP to unsubscribe):</h4>
<div class="contact"></div>
<!-- Chat inputs/output -->
<textarea readonly value="Awaiting messages..."></textarea>
<input placeholder="enter a message..."/>
<button class="button">Send Message</button>
<p class="footer">
Source on <a href="">Github</a>.
Released under <a href="">MIT license</a>.