Skip to content

Instantly share code, notes, and snippets.

@bradhintze
Created November 21, 2010 00:41
Show Gist options
  • Save bradhintze/708310 to your computer and use it in GitHub Desktop.
Save bradhintze/708310 to your computer and use it in GitHub Desktop.
Customer Feedback Line using Twilio and Kynetx
meta {
name "TSA Customer Feedback"
description <<
Customer Feedback Number
>>
author "Sam"
logging off
key twitter {
"consumer_key" : "REDACTED",
"consumer_secret" : "REDACTED",
"oauth_token":"REDACTED",
"oauth_token_secret":"REDACTED"
}
}
dispatch {}
global {
}
rule callconnected {
select when twilio callconnected
twilio:say("Thank you for calling T S A Customer Feedback.");
always {
raise explicit event givemenu;
}
}
rule givemenu {
select when twilio givemenu or explicit givemenu
pre {
menutext = <<
if you are happy with your recent security screening press 1,
if you want more invasive scanning machines, press 2,
If you want a more thorough pat down, press 3,
To hear these options again, press 0
>>;
}
{
twilio:gather_start("menuchoice") with numDigits = 1;
twilio:say(menutext);
twilio:gather_stop();
twilio:redirect("givemenu");
}
}
rule repeat {
select when twilio menuchoice Digits "0"
twilio:redirect("givemenu");
}
rule alloptions {
select when twilio menuchoice Digits "([123])" setting (choice)
pre {
choices = {
'1':'Everything is perfect!',
'2':'Request for more invasive scanning machines.',
'3':'Request for more thorough pat down.'
};
city = event:param("FromCity");
state = event:param("FromState");
feedback = choices.pick("$.#{choice}");
tweet = "Customer Feedback from #{city}, #{state}: #{feedback} Please call us! 888-418-3011 #tsa";
}
{
twitter:update(tweet);
twilio:say("Thank you for your feedback.");
twilio:gather_start("sendsms") with numDigits = 1;
twilio:say("If you would like to share this with your friends with a text message, press 1. Or press 0 to end this call.");
twilio:gather_stop();
}
}
rule badchoice {
select when twilio menuchoice Digits "([456789])" setting (badchoice)
twilio:say("#{badchoice} is not a valid option.");
fired {
raise explicit event givemenu;
}
}
rule sendsms {
select when twilio sendsms Digits "1"
{
twilio:sms("Please try the TSA Customer Feedback line: 888-418-3011") with from ="+18018954878";
twilio:say("You have been sent a text message. Please forward it to your friends.");
}
fired {
raise explicit event endcall;
}
}
rule endcall {
select when twilio sendsms Digits "[023456789]" or explicit endcall
{
twilio:say("Thank you for calling. Goodbye");
twilio:hangup();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment