login | register
Sat 04 of Jul, 2009 [06:13 UTC]

voip-info.org

Discuss [5] History

Asterisk tips Wake-Up Call PHP with Snooze/Annoy

Created by: JonR,Last modification on Tue 10 of Jan, 2006 [17:32 UTC]
I recently updated my annoy script for Andy Wysocki's Wake Up Call. It works the same as Andy's until you get the actual wake up call. From there you can either cancel or set a snooze of your choice. If you choose cancel you have to answer a simple addition problem to prove you're mildly coherent.

Installation instructions are pretty much the same, dump these files in your agi-bin and mark them executable. Create an extension that launches the wakeup.php AGI.

Current Issue:
  • Requires $parm_chan_ext to be set to 1, otherwise after the first wakup call it won't know where to send the call for the second. I'm sure there's another way around this I just haven't put the time into it.

Files:
  • wake.inc: variables for both scripts
  • wakeup.php: Andy's original wake up php, modified to use wake.inc
  • wakeconfirm.php: The script that confirms the person is awake or sets a snooze

Download attached .tar.gz which includes files mentioned above.
Image


See Also:
Asterisk tips Wake-Up Call PHP

Comments

Comments Filter
222

333Bugs :)

by JonR, Saturday 22 of July, 2006 [18:33:00 UTC]
I resolved most of the bugs listed here. I set it to create another wakeup call upon answer in case the user hangs up.

The 5 minute thing I fixed as well. Purely a cut/paste error.

Daniel's stuff sounds great.. I'll have to check out his code.
222

333Annoy Issue Resolution

by Pumbaa2, Saturday 06 of May, 2006 [01:05:05 UTC]
In regards to not getting a call back on hangup.

    To resolve the issue with the wakeup calls ending on hangup is pretty easy.  Asterisk kills the call file
upon answer. So when it answers just make the AGI generate another .call file. Set the time limit to
something like 10 minutes and you could even make it run the snooze script with a parm that tells the
script that the last call was disconnected. This way you can make it say something like "hahahah, it's not
that easy to get out of waking up, lol!  If they reschedule a call back due to snooze then make the script
kill the created file.  The filename can be easily stored in a variable once created.  Make the script create
the correct call back and kill that file.  The only problem with this is it may try to call you back if you take 
longer than 10 minutes dealing with the script which on some SIP/IAX lines will cause call waiting, etc.
I would make sure the script has a timeout for those who may fall back asleep answering the annoy script
so a clean hangup is done and set the channel variable to "FAILED" in this instance as well. Most VoIP
devices are smart enough to release the line and go back into a idle status, hints the next call should ring
the phone again.  The only problem would be for ATA VoIP to Analog devices because those devices 
don't know how to release the line. Cell phones wouldn't be a problem however.

    The second solution is to make a hangup extension to the alarm.  Then when the call is hung up make
it check a asterisk channel variable that would be set by the snooze script to see if it completed successfully.  
Upon call in make the script set the variable to "FAILED" by default and change it to "SUCCESS" if
everything the script demanded for is completed. On the hangup extension make it run the script again
with a parm of "hangup". The only task for the script will be to check the channel variable which will be
"FAILED", "SUCCESS" or "". If it's failed then set a call back of 1 minute if you really want to be a prick
about it. If it's set to SUCCESS then just exit the script normally and do nothing. You know at this point
the initial script execution completed the job for you. The same would be true if it's set to "" because that
would mean the script didn't execute at all or there was a internal issue such as the PHP or PERL interpreter
was missing or invalid or the code crashed before setting up that channel variable.

I would say make the hangup script call the person right back but I really don't think extension "hh" exists
for hanging up on the hang up extension. So that would result in no more calls back which may not be a
bad thing because at that point I'm sure they're annoyed which was the point! lol.

I hope this helps.

-RayRay-

P.S. Why doesn't this website know how to line wrap. I had to manually break my paragraph down! Silly
222

333Annoy Issue

by Eggbert, Saturday 08 of April, 2006 [19:57:37 UTC]
I just set this package up and it is really neat and works well. However, I have found two issues.

1) If you answer the phone and then hang up the wakeup calls will end - without having to answer the math problem.
2) If you snooze for any amount of time it will always say "5 minutes" but will call back in the requested time interval.

I was wondering if:

a) Anyone else has experienced this
b) If anyone has found solutions to this
c) Guidance on what block of code I would need to hack up in order to schedule a new wake up call if the user simply picks up, and hangs up.

Thanks,
James
222

333not requiring $parm_chan_ext

by 121mhz, Monday 27 of March, 2006 [00:26:08 UTC]
I made some changes to the awesome work done by JonR and Andy Wysocki that some people might like to have.


I commented out the requirement that you do math to cancel the annoy, I'd have enough trouble pressing 1, forget about figuring out math before 3 cups of coffee.
I also added support for calling in from an outside phone (like a cell phone) as both my wife and I need wakeup calls and usually use our cell phones for it. You should be aware that wakeconfirm understands a caller id of less than or equal to 4 numbers as a local extension and greater than that is an outside extensions. If the call back number is an outside extension, the system adds $parm_dial_out_prefix to the front of the number to be called and $parm_dial_out_postfix to the end. That helps me make the call over an IAX2 interface with voipjet.
I made it so that if you don't answer, you get a call back in two minutes; therefore you MUST answer 1 in order to get it to stop calling! (this was added after I slept through the first call and there was no second; oops)


The code is available here: http://www.dataixl.com/asterisk/asteriskwake.tar.gz

Installation Instructions:
wakeup.php, wakeconfirm.php and wake.inc need to be in your agi-bin directory (usually /var/lib/asterisk/agi-bin)
>the contents of extensions.inc need to be part of your extensions.conf file (do a copy and paste or "cat extensions.inc >>/etc/asterisk/extensions.conf")


The basic idea is that when wake.php creates the outgoing spool file, it will tell asterisk to create the call in the wake confirm context where any dialed number reaches wakeconfirm. Then wakeconfirm can read the number dialed to know what number to call back if necessary.

This worked for me; but no guarantee it'll work for you. I don't have A@H so I haven't tried it there.
222

333not requiring $parm_chan_ext

by 121mhz, Monday 27 of March, 2006 [00:19:18 UTC]
<duplicate>