<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message>Discover your power to change the world with code! https://twilio.com/quest</Message>
</Response>
exports.handler = function (context, event, callback) {
console.log(`Body was ${event.Body}`);
const twiml = new Twilio.twiml.MessagingResponse();
if (event.Body.toUpperCase() === "QUEST") {
twiml.message(
"Discover your power to change the world with code! https://twilio.com/quest"
);
} else {
twiml.message(
`I don't know what you mean by "${event.Body}". Did you mean QUEST?`
);
}
console.log(`TwiML: ${twiml}`);
return callback(null, twiml);
};
- 📚 Helper Libraries
- 📚 Messaging Services Best Practices at Scale
- 🙋♂️ Support - Adding a verified phone number
Here are some practice and example applications for you to experiment with. Let us know how it's going @TwilioDevs or in the community
- 💡 Create an SMS auto-responder that shares a link to one of your favorite web applications
- 💡 Build a dynamic SMS based magic 8-ball app using Twilio Functions
- 🧪 Build SMS Appointment Reminders
- 👩💻 CodeExchange - SMS Forwarding
- 👩💻 CodeExchange - Send browser based SMS notifications
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Ahoy World!</Say>
</Response>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="Polly.Matthew-Neural">And now an important message:</Say>
<Play>https://twil.io/professional-recording-example</Play>
</Response>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="Polly.Matthew-Neural">And now an important message:</Say>
<Gather numDigits="1" action="https://exploration-[YOUR DIGITS HERE].twil.io/handle-feedback">
<Say voice="Polly.Matthew-Neural">Press 1 to approve of this joke, Press 2 to talk to a manager</Say>
<Play>https://twil.io/professional-recording-example</Play>
</Gather>
<Say>You listened to the whole song! Way to never give up!</Say>
</Response>
exports.handler = function (context, event, callback) {
const twiml = new Twilio.twiml.VoiceResponse();
console.log(`User pressed ${event.Digits}`);
if (event.Digits === "1") {
twiml.say("That's great! Glad we didn't let you down!");
} else if (event.Digits === "2") {
//TODO: Look up user from phone number => event.From
const name = "Karen";
twiml.say(
`Thank you for reporting this joke, ${name}, connecting you with a supervisor`
);
twiml.enqueue("managers");
} else {
twiml.say(`You pressed ${event.Digits}...but why?`);
}
return callback(null, twiml);
};
If you had a phone number you could set a dial in number to use the following TwiML Bin on incoming calls. You'd then just have the manager call this number and they'd get the next caller in the queue!
<Response>
<Dial>
<Queue>managers</Queue>
</Dial>
</Response>
- 📚 Twilio CLI
- 👩💻 Twilio CLI Debugger Plugin
- 📚 Call Resource Status Callback
- 📚 Messaging Status Callback pattern
- 📚 Answering Machine Detection
- 👩💻 Modify Calls in Progress - Tutorial
exports.handler = function (context, event, callback) {
console.log(`Call: ${event.CallSid} status ${event.CallStatus}`);
return callback(null);
};
- 📚
<Gather>
input
attribute - 📚 Answering Machine Detection
- 🙋♂️ Sending and Receiving Limitations on Calls and SMS Messages
- 👀 Media Streams - Build realtime voice applications
- 👀 SIP Interface - Programmatic Voice over Internet or Voip calls
- 👀 Elastic SIP Trunking
- 👀 Voice SDK - Client side (browser/mobile) voice applications
Here are some practice and example applications for you to experiment with. Let us know how it's going @TwilioDevs or in the community
- 💡 Using a Twilio Function as an incoming call handler, create a call-in hotline that reports the weather using a weather API
- 💡 Create an answering machine using the
<Record> TwiML verb
that texts you the transcription via thetranscribeCallback
- 🧪 Tutorial - How to Build Call Forwarding
- 👩💻 CodeExchange - Basic IVR
- 👩💻 CodeExchange - Pin Protected Conference Line
You can view all the completed PhoneMO source code.
- 🎁 Looking for a promo code to upgrade your account out of trial mode? Send me a text message with the word
promo
in it. - 👀 Most Popular Social Audio Apps in 2021
⏰⏰⏰⏰⏰⏰
Whoops! I mistakenly put muted: false
but I meant muted: true
! We want callers that aren't the speakers to be silent. Sorry about that!
⏰⏰⏰⏰⏰⏰
// Keep track of when a user does something unexpected and then flip the a showHelp boolean
if (showHelp) {
const talks = data.getUpcomingTalks();
const options = talks.map(talk => `For ${talk.title}: join ${talk.code}`);
twiml.message(options.join("\n"));
}
- ⚙️ Console - Change your CPS - Calls Per Second
- 👀 JavaScript Promises - MDN
- 👀 JavaScript async functions - MDN
- 📲 Give me a call or send me a text +15038368731 and let me know how you felt about the course! I used Studio to build both the Messaging and Voice flows. Import the flows.
- 💡 Build an entirely Serverless Voice Mail application! Wire up the incoming number to a Twilio Function that uses the
<Record>
verb. Turn on transcription and use the webhook to send the transcription to a number specified in an environment variable. - 👩💻 CodeExchange - Call Forwarding with Voicemail
- 💡 Create a client-side browser based phone so anyone can listen in from the website
- 💡 Host a static web page using Twilio Assets and expose the data through APIs to display the schedule of upcoming talks