Skip to content

Instantly share code, notes, and snippets.

@zackproser
Created July 21, 2015 05:34
Show Gist options
  • Save zackproser/0e93a487206be264b16e to your computer and use it in GitHub Desktop.
Save zackproser/0e93a487206be264b16e to your computer and use it in GitHub Desktop.
An example function for generating Twiml for Twilio to parse during a phone call.
/**
* Generates valid Twiml that creates the Super CatFacts Attack Call Center menu experience
*
* @return {String} response - valid Twiml xml complete with say, play and gather commands
*/
function generateCallResponseTwiml() {
var response = new twilio.TwimlResponse();
response.say("Thank you for calling Cat Facts!", {
voice: 'man',
language: 'en'
})
.play(config.server_root + '/sounds/shortMeow.wav')
.say("Cat Facts is the number one provider of fun facts about cats! All of our representatives are currently assisting other cat lovers. Please remain on the feline! In the meantime, please listen carefully as our menu options have recently changed.", {
voice: 'man',
language: 'en'
})
.gather({
action: config.server_root + '/catfacts-call-menu',
finishOnKey: '*'
}, function(){
this.say("If you would like to receive a fun cat fact right now, press 1. If you would like to learn about how you were subscribed to CAT FACTS, please press 2", {
voice: 'man',
language: 'en'
})
.say("If for some fur-brained reason you would like to unsubscribe from fantastic hourly cat facts, please press 3 3 3 3 4 6 7 8 9 3 1 2 6 in order right now", {
voice: 'man',
language: 'en'
})
});
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment