Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove the text adventure game, use SMS voting instead

  • Loading branch information...
commit f271dd528741924df836a2984ebb7d6ec0b1700a 1 parent 21b3e0b
@kyleconroy kyleconroy authored
View
BIN  docs/_static/voiceurl.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
7 docs/callin.rst
@@ -9,9 +9,10 @@ using Twilio's new <Queue> functionality.
Using the Twilio Helper Libraries
---------------------------------
-Though this workshop will assume use of Python and the twilio-python
-helper library, Twilio offers helper libraries for a large set of
-languages. Check them out `here`_.
+Though this workshop will assume use of Python and the twilio-python helper
+library, Twilio offers helper libraries for a large set of languages. If you
+aren't using Python, download the `helper library`_ for your language of
+choice. You'll need the library in the next section.
For the twilio-python helper library, you may find the `Queue API
Reference`_ helpful for this workshop.
View
2  docs/custom_twiml.rst
@@ -79,6 +79,8 @@ Go to `your Twilio numbers page
your Twilio phone number. Change the "Voice URL" field to your Twimlbin URL and
"Save Changes"
+.. image:: _static/voiceurl.png
+
Now give your Twilio number a call! You should hear a "Hello World" greeting.
Call Logs & SMS Logs
View
17 docs/deploy.rst
@@ -1,17 +0,0 @@
-.. _deploy:
-
-Create a SMS adventure game
-===========================
-
-We've created some smaller Twilio applications Today, but we're now ready for
-the final app. We're going to create a distributed text-adventure game. Players
-will text in commands to progress.
-
-Processing Input
-----------------
-
-Text-Adventure Game Basics
---------------------------
-
-Exchange URLs with other workshop members
------------------------------------------
View
45 docs/dynamic_apps.rst
@@ -181,7 +181,7 @@ dynamic application is so powerful. First, a simple example.
self.response.headers['Content-Type'] = "application/xml"
response = twiml.Response()
- respone.say("Hello " + self.request.params('FromNumber'))
+ respone.say("Hello " + self.request.params('From'))
self.response.write(str(response))
app = webapp2.WSGIApplication([
@@ -189,26 +189,48 @@ dynamic application is so powerful. First, a simple example.
], debug=True)
-Now visit your page. You'll see the message "Hello " without a name. To add a
-name to your message add a parameter to your URL.
+Now visit your page. You'll see the following message.
+
+.. code-block:: xml
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <Response>
+ <Say>Hello </Say>
+ </Response>
+
+
+It seems that our message is missing a phone number. To test out the greeting,
+add the ``From`` parameter to your URL.
.. code-block:: bash
- http://localhost:8080/?From=+5005550000
+ http://localhost:8080/?From=+15005550000
+
+You should now see a the phone number show up in your TwiML response.
+
+.. code-block:: xml
+
+ <?xml version="1.0" encoding="UTF-8"?>
+ <Response>
+ <Say>Hello +15005550000</Say>
+ </Response>
Whenever an HTTP request is sent to your application it includes data in query
-string and body of the request. The code we added when constructing the Say verb pulls the named request parameter from either a POST or GET request parameter.
+string and body of the request. The code we added when constructing the Say
+verb pulls the named request parameter from either a POST or GET request
+parameter.
.. code-block:: python
- self.request.params('FromNumber')
+ self.request.params('From')
Incoming Twilio Data
~~~~~~~~~~~~~~~~~~~~
Adding this parameter to your URL mimics the request that Twilio will send to
your server. All TwiML requests made by Twilio include additional information
-about the caller. Here is short list of some of the data that Twilio will send your way.
+about the caller. Here is short list of some of the data that Twilio will send
+your way.
============== ===========
Parameter Description
@@ -219,7 +241,8 @@ Parameter Description
``Body`` The text body of the SMS message. Up to 160 characters long.
============== ===========
-Phone numbers are formatted in E164 format (with a '+' and country code, e.g. `+1617555121`).
+Phone numbers are formatted in E164 format (with a '+' and country code, e.g.
+`+1617555121`).
Deploy your Twilio application
------------------------------
@@ -231,8 +254,8 @@ deployemnt. It should take less than a minute to deploy.
.. image:: _static/deployapp.png
-Once it's deployed get the url for your application and set it as the voice
-number for your Twilio phone number. Just like you've done in previous
-sections.
+Once it's deployed, take the url for your application and set it as the voice
+number for your Twilio phone number. Configuring Twilio numbers is covered in
+more detail in :ref:``
Now give it a call. You should hear your custom message. Hooray!
View
94 docs/static_apps.rst
@@ -3,7 +3,9 @@
Building Static Applications
=============================
-Congratulations! Now that you've built and debugged your first Twilio application, let's start building Twilio applications with some of the other TwiML verbs. These applications can be hosted on `Twimlbin`_.
+Congratulations! Now that you've built and debugged your first Twilio
+application, let's start building Twilio applications with some of the other
+TwiML verbs. These applications can be hosted on `Twimlbin`_.
Call Forwarding
@@ -25,20 +27,54 @@ neighbor to test it out.
Twilio Call Legs
~~~~~~~~~~~~~~~~~
-Find this call in your `Call Logs <https://www.twilio.com/user/account/log/calls>`_. You should notice two call records listed. What's the difference between the two call records?
+Find this call in your `Call Logs
+<https://www.twilio.com/user/account/log/calls>`_. You should notice two call
+records listed. What's the difference between the two call records?
-- **Direction:** For applications like Call Forwarding, your call will include two call legs. The inbound call leg noted under *Incoming* is the call made into Twilio. The outbound call leg noted under *Outgoing Dial* is the call made from Twilio with the Dial verb out to another phone number. Call Forwarding applications include both an inbound leg and an outbound leg.
-- **Cost:** The cost of inbound and outbound calls are different. Inbound calls cost 1¢ per minute while outbound calls start at 2¢ per minute. The cost of outbound calls may also differ depending on the end destination of your outbound call. See the `Voice Pricing`_ Page for more pricing information.
-- **To:** While the "From" phone numbers are the same, the "To" phone number are different based on the phone number receiving your call.
+Direction
+`````````
-Introducing Attributes
-------------------------
+For applications like Call Forwarding, your call will include two call legs.
+The inbound call leg noted under *Incoming* is the call made into Twilio. The
+outbound call leg noted under *Outgoing Dial* is the call made from Twilio with
+the Dial verb out to another phone number. Call Forwarding applications include
+both an inbound leg and an outbound leg.
+
+Cost
+````
+
+The cost of inbound and outbound calls are different. Inbound calls cost 1¢ per
+minute while outbound calls start at 2¢ per minute. The cost of outbound calls
+may also differ depending on the end destination of your outbound call. See the
+`Voice Pricing`_ Page for more pricing information.
-Each TwiML verb and noun has a set of attributes that allow you to modify its behavior. Let's change our robot voice to a female voice by adding the `voice attribute <http://www.twilio.com/docs/api/twiml/say#attributes-voice>`_ and setting it to "woman". Additionally, let's record our call by including the `record attribute <http://www.twilio.com/docs/api/twiml/dial#attributes-record>`_ and mark that as "true".
+To
+``
-For our last call, the caller ID displayed was the phone number where the call originated from. Let's change your caller ID using the `callerId attribute <http://www.twilio.com/docs/api/twiml/dial#attributes-caller-id>`_ so that it displays your Twilio phone number instead. Earlier we verified your personal phone number so you may also use that as your caller ID. To use other phone numbers as your caller ID you can verifying those numbers in your Twilio Account.
+While the "From" phone numbers are the same, the "To" phone number are
+different based on the phone number receiving your call.
+
+Introducing Attributes
+------------------------
-Test out the following code and see how the attributes have changed your application.
+Each TwiML verb and noun has a set of attributes that allow you to modify its
+behavior. Let's change our robot voice to a female voice by adding the `voice
+attribute <http://www.twilio.com/docs/api/twiml/say#attributes-voice>`_ and
+setting it to "woman". Additionally, let's record our call by including the
+`record attribute
+<http://www.twilio.com/docs/api/twiml/dial#attributes-record>`_ and mark that
+as "true".
+
+For our last call, the caller ID displayed was the phone number where the call
+originated from. Let's change your caller ID using the `callerId attribute
+<http://www.twilio.com/docs/api/twiml/dial#attributes-caller-id>`_ so that it
+displays your Twilio phone number instead. Earlier we verified your personal
+phone number so you may also use that as your caller ID. To use other phone
+numbers as your caller ID you can verifying those numbers in your Twilio
+Account.
+
+Test out the following code and see how the attributes have changed your
+application.
.. code-block:: xml
@@ -50,13 +86,16 @@ Test out the following code and see how the attributes have changed your applica
</Dial>
</Response>
-Try out some of the other `Say`_ verb and `Dial`_ verb attributes and see what they do.
+Try out some of the other `Say`_ verb and `Dial`_ verb attributes and see what
+they do.
Voice Mailbox
-------------
Recording audio is accomplished through the `Record`_ verb. The Record verb
-will play a beep and wait until a user presses # or hangs up. While the record attribute used earlier will record both sides of the conversation, the `Record`_ verb is used to record just the inbound call leg. Copy this TwiML
+will play a beep and wait until a user presses # or hangs up. While the record
+attribute used earlier will record both sides of the conversation, the
+`Record`_ verb is used to record just the inbound call leg. Copy this TwiML
into your bin and save. You can now leave messages on your number.
.. code-block:: xml
@@ -75,7 +114,9 @@ message.
Transcription
~~~~~~~~~~~~~~
-Transcriptions of your recordings can also be made by Twilio with the `transcribe attribute <http://www.twilio.com/docs/api/twiml/record#attributes-transcribe>`_
+Transcriptions of your recordings can also be made by Twilio with the
+`transcribe attribute
+<http://www.twilio.com/docs/api/twiml/record#attributes-transcribe>`_
.. code-block:: xml
@@ -88,17 +129,18 @@ Transcriptions of your recordings can also be made by Twilio with the `transcrib
Rerecord your message. This time record a longer message.
Head over to your `transcription log
-<https://www.twilio.com/user/account/log/transcriptions>`_ to see your transcription and listen to your message.
+<https://www.twilio.com/user/account/log/transcriptions>`_ to see your
+transcription and listen to your message.
Private Conference Line
-----------------------
-Many times during project assignments you just need to get everyone on the
-same page. You can now have your own private conference line using the
-`Conference`_ noun and `Dial`_ verb. Put the following TwiML into your bin and save.
-Give your Twilio number to a few people around you. Have everyone call in and
-start up a conversation.
+Many times during project assignments you just need to get everyone on the same
+page. You can now have your own private conference line using the `Conference`_
+noun and `Dial`_ verb. Put the following TwiML into your bin and save. Give
+your Twilio number to a few people around you. Have everyone call in and start
+up a conversation.
.. code-block:: xml
@@ -113,7 +155,8 @@ start up a conversation.
One Song Music Hotline
-----------------------
-To play an audio file back to the caller use the `Play`_ verb. We can build a simple music hotline that just plays just one song to the caller.
+To play an audio file back to the caller use the `Play`_ verb. We can build a
+simple music hotline that just plays just one song to the caller.
.. code-block:: xml
@@ -146,13 +189,18 @@ Equipped with the knowledge of TwiML you can now bend your Twilio phone number
to your will. You've forwarded a call, recorded a message, and started a
private conference line. Your phone is now your's to control.
-But with this many applications we definitely want more than one Twilio phone number. Let's purchase another number.
+But with this many applications we definitely want more than one Twilio phone
+number. Let's purchase another number.
-To purchase a Twilio phone number you will want to navigate to the `Numbers <https://www.twilio.com/user/account/phone-numbers/incoming>`_ tab. Click on the blue button titled `Buy a number <https://www.twilio.com/user/account/phone-numbers/available/local>`_.
+To purchase a Twilio phone number you will want to navigate to the `Numbers
+<https://www.twilio.com/user/account/phone-numbers/incoming>`_ tab. Click on
+the blue button titled `Buy a number
+<https://www.twilio.com/user/account/phone-numbers/available/local>`_.
.. image:: _static/buy_number.png
-You may search for the Twilio phone number you would like to purchase by the area code, digits, and phrases as well as by the location.
+You may search for the Twilio phone number you would like to purchase by the
+area code, digits, and phrases as well as by the location.
.. _Twimlbin: http://twimlbin.com
.. _Voice Pricing: http://www.twilio.com/voice/pricing
View
25 main.py
@@ -1,36 +1,11 @@
-import os
-
-from google.appengine.ext.webapp import template
-import twilio
import webapp2
-
-ACCOUNT_SID = "ACXXX"
-AUTH_TOKEN = "XXX"
-APP_SID = "APXXX"
-# Utility functions
-
-
-def render_template(rel_path, parameters=None, folder="templates"):
- """
- Takes a path relative to the templates/ folder and
- an optional parameter for variables to render to the template.
- """
- parameters = parameters if parameters is not None else {}
- path = os.path.join(os.path.dirname(__file__), folder, rel_path)
- return template.render(path, parameters)
-
-
-# Request Handlers
-
class HelloWorld(webapp2.RequestHandler):
def get(self):
self.response.write('Hello World!')
-# URL Mappings
-
app = webapp2.WSGIApplication([
('/', HelloWorld),
], debug=True)
View
11 util.py
@@ -0,0 +1,11 @@
+import os
+from google.appengine.ext.webapp import template
+
+def render_template(rel_path, parameters=None, folder="templates"):
+ """
+ Takes a path relative to the templates/ folder and
+ an optional parameter for variables to render to the template.
+ """
+ parameters = parameters if parameters is not None else {}
+ path = os.path.join(os.path.dirname(__file__), folder, rel_path)
+ return template.render(path, parameters)
Please sign in to comment.
Something went wrong with that request. Please try again.