Hardware Reference
In-Depth Information
The stuff between the tags is the content of an element.
It's usually the stuff that humans want to read, but that the
machines don't care about.
Voice elements:
<Say>
<Play>
<Gather>
<Record>
<Sms>
<Dial>
<Number>
<Conference>
<Hangup>
<Redirect>
<Reject>
<Pause>
Every element should have an opening and closing tag,
though sometimes a tag can close itself, like this:
<Pause length="10" />
What's inside a tag other than the tag's name are its attri-
butes . The length above is an attribute of a Pause , and this
specific pause's length is 10 seconds. Attributes allow you
to describe elements in great detail.
If you're thinking all of this looks like HTML, you're right.
XML and HTML are related markup languages, but XML's
syntax is much stricter. Because it's such a general
language, though, it's possible to write XML-parsing
programs that work from one schema to another.
SMS elements:
<Sms>
<Redirect>
They're all explained in depth on Twilio's documentation
pages, but you can probably guess what most of them do.
TwiML
Twilio's markup schema, TwiML, is a description of the
functions Twilio offers written in XML. It describes what
you can do with Twilio. There are elements for handling a
voice call, and elements for handling an SMS message.
The list of elements is pretty short:
For this project, you're going to describe a <Response> .
Within that, you'll use <Gather> to collect keypresses
from the caller. The <Gather> element is TwiML's version
of an HTML form, so it has an action attribute and a
method attibute that you'll use to tell it where and how
to send its results. You'll also use the <Say> element to
speak to the caller using text-to-speech.
X
Mark It up
There's only one TwiML
document you need for
this project. When a caller dials in, this
document will be the initial response;
when she enters keypresses, the
document will call itself again to update
the settings. Save it as voice.xml to the
SD card from your previous project.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="voice.xml" method="POST">
<Say>
The current temperature is
$temperature
degrees Celsius.
The thermostat is set to $thermostat degrees Celsius.
The air conditioner is $status.
If you would like to change the thermostat, please enter
a new setting.
If you are satisfied, please hang up.
</Say>
</Gather>
<Say>
You can see the same variables from
your previous project: $temperature ,
$thermostat , and $status . The server
will replace them just like it does with
the HTML documents. That part of
your sketch won't need to change.
You didn't give a new setting,
The changes that need to be made to
the server sketch follow on the next
page.
so the thermostat will remain at $thermostat degrees. Goodbye!
</Say>
</Response>
Search WWH ::




Custom Search