RSS
 

Redial Midterm: Gotta Take This

07 Mar

For my Redial midterm, I did something functionally pretty straight-forward.  Ever been in a situation where you’re talking to someone and you want to get out of it, like when that person is one of those folks who just keeps going and going and you haven’t said a word in ten minutes because they wouldn’t you talk?  Or if the conversation is so forced and awkward that you can’t stand it?

I’ve got an app for you.

It’s called Gotta Take This, although I think I pitched it originally as Panic Button.  I think I chose the former because it sounded a little less alarmist but still conveying the purpose.

What the app does is, upon opening it on your phone, it shows you a life preserver.  Tap on the preserver and casually exit to something else on your phone, like checking email.

Five minutes later (I set this to 1 minute for the demo), you’ll get an “Urgent Call” from a pre-set number.  When you answer it, an Asterisk dialplan takes over and plays, for my demo anyway, a long recorded message that gives you plenty of cover to have a quick conversation.

This gives you multiple opportunities to tell your present company, “Hey, uhh, I gotta take this…  It’s urgent/important/just a quick call/getting information.”

Now, once you’ve moved away with the call, you’re free to slink out of the place, or distractedly fall into a conversation with other people.

The app is made for Android with PhoneGap.  I got the icon from iconmaker.com.  The PhoneGap app’s button triggers jQuery Mobile to go to a ruby script I set up on ITP’s server, which generates a callfile with pre-set call information to be executed at a certain time in the future.

My ruby script, running via Sinatra:

require "rubygems"
require "sinatra"

# Main route  - this is the form where we take the input
get '/gottatakethis' do
  minutes = 1
  t = Time.now + (60 * minutes)
  # %H-%M-%S-%m-%d-%Y == 09-09-03-07-24-2006
  timeCallBack = t.strftime("%H-%M-%S-%m-%d-%Y")
  numbertocall = 15555555
  senderNum = 15555555

  # set the temp dir & filename & destination path to write from/save to
  temp_dir = "/tmp/"
  callfile = "call_" + timeCallBack + ".call"
  startcallfile = temp_dir + callfile
  end_dir = "/var/spool/asterisk/outgoing/"
  endcallfile = end_dir + callfile

  #write file to disk
  file = File.open(startcallfile,"w")
  file.puts("Channel: SIP/itp_jnctn/#{numbertocall}\n")
  file.puts("MaxRetries: 2\n")
  file.puts("RetryTime: 60\n")
  file.puts("WaitTime: 30\n")
  file.puts("Context: vt520_gtt\n")
  file.puts("Extension: 1\n")
  file.puts("CallerID: Urgent Call ")
  file.close

  #change file permission
  File.chmod(0777, startcallfile)
  FileUtils.chown(ENV['USER'],'asterisk',startcallfile)

  #move file to /var/spool/outgoing
  if (timeCallBack != "")
	timesplit = timeCallBack.split('-')
	ctime = Time.local(timesplit[5],timesplit[3],timesplit[4],timesplit[0],timesplit[1],timesplit[2])
	File.utime(ctime,ctime,startcallfile) #change file time to future date
  end
  FileUtils.mv(startcallfile,endcallfile)

  body = "Sent."
  body

And the relevant dialplan:

[vt520_gtt]
exten => s,1,Answer()
   same => n,Wait(3)
   same => n,Playback(/home/vt520/asterisk_sounds/soundfile)
   same => n,Hangup()
 
No Comments

Posted in ITP, Redial