Skip to content

Instantly share code, notes, and snippets.

View marks's full-sized avatar

Mark Silverberg marks

View GitHub Profile
call('[email protected]', [
network: 'GMAIL',
onAnswer: {
ask("Hey, did you remember to take your pills?", [
timeout: 120,
choices: 'yes(yes,y,1), no(no,n,2)',
onChoice: { event->
if(event.value == "yes") {
say "ok, just checkin."
} else {
answer()
ask("Welcome to the Tropo company directory. Who are you trying to reach?", [
choices: "department(support, engineering, sales), person(jose, jason, adam)",
onChoice: { event->
switch(event.value) {
case "department":
log("Department info: $event.choice.interpretation")
break
case "person":
log("Person info: $event.choice.interpretation")
answer()
result = ask("What's your favorite color?", [
choices: "red, blue, green"])
log("They said: $result.value")
hangup()
answer()
result = ask("What's your favorite color?", [
attempts: 3,
choices: "red, blue, green",
onBadChoice: { event->
switch(event.attempt){
case 1:
say "We don't support that color. You can say red, blue or green."
break
case 2:
answer()
record("Please leave your message at the beep.", [
beep: true,
timeout: 10,
silenceTimeout: 7,
maxTime: 60,
onRecord: { event->
log("Recording result = " + event.recordURI)
say("You said " + event.recordURI)}
])
answer()
startCallRecording("http://myServer.com/recordings/testfile.wave", [
transcriptionOutURI: "mailto:[email protected]"])
//continue with your script here
stopCallRecording()
hangup()
answer()
say("Please wait while we transfer your call")
transfer("tel:+14075551212", [
playvalue: "http://myServer.com/ElevatorMusic.wav",
onTimeout: { event->
say "Sorry, but nobody answered" }
])
<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar"
     xml:lang="en-US" root = "MYRULE">
 <rule id="MYRULE" scope="public">
   <one-of>
     <item>james brown </item>    </one-of>
 </rule>
</grammar>
<?xml version= "1.0"?>
answer()
ask("What's your four digit pin?", [
choices: "[4 DIGITS]",
mode: "voice",
recognizer: "en-us", // will recognize 'one two three four'
onChoice: {event -> say("You said $event.value")}
])
answer()
ask("¿Cuál es su número de identificación?", [
answer()
say("Welcome to the geek singles hotline!")
conference("1337", [terminator: "*"])
say("We hope you had fun, call back soon!")
hangup()