Paging For Praying

Home » Asterisk Users » Paging For Praying
Asterisk Users 21 Comments

Hello;

How can I have Paging on Asterisk to call for pray?

The pray is 5 times in a day and there is a timing for pray (actually it can be existed in a text file or database for the next 2 or 5 years).

My question is compound from two parts:

How can I have Automatic Page?

The automatic page should happens by reading the time and check if the time is same as this time, then do the Page. How? Is it by cron?

Someone told me that do a cron that call a script which will check the time, if the time came to do th Page, then do a Page. But really I do not know how this can be done and I do not know if this is already existed?

Regards Bilal

21 thoughts on - Paging For Praying

  • I dont think this is existed.

    However, its easy to build a script in php or perl or any other language which check time from file or database and generate call file which execute paging in asterisk. Just put this script in cron. Thats it…

    Regards,

    Bharat Lalcheta

  • I would set up 5 shell files called pray1.sh, pray2.sh, etc and then set up
    5 entries in /etc/crontab to run them at the specified time daily. The file pray1.sh should look something like this:

    #!/bin/sh

    cp /pray1/*.call /tmp

    mv /tmp/*.call /var/spool/asterisk/outgoing

    the entry in /etc/crontab would look like this

    0 8 *** root /usr/bin/pray1.sh

    This would run pray1.sh at 8 am daily.

    From: asterisk-users-bounces@lists.digium.com
    [mailto:asterisk-users-bounces@lists.digium.com] Hello;

    How can I have Paging on Asterisk to call for pray?

    The pray is 5 times in a day and there is a timing for pray (actually it can be existed in a text file or database for the next 2 or 5 years).

    My question is compound from two parts:

    How can I have Automatic Page?

    The automatic page should happens by reading the time and check if the time is same as this time, then do the Page. How? Is it by cron?

    Someone told me that do a cron that call a script which will check the time, if the time came to do th Page, then do a Page. But really I do not know how this can be done and I do not know if this is already existed?

    Regards Bilal

  • Thanks a lot for your kindly reply and help.

    Really I did not understand why you need to place them in the /var/spool/asterisk/outgoing?

    Regards Bilal

    ————-

  • Please don’t top-post.

    The appropriate solution needs a lot more detail to be useful.

    Is this just to remind you or is this the foundation of a new product for thousands of customers?

    Is there a message or verse associated with each of the 5 reminders or is
    ‘time to pray’ sufficient?

    Is there a penalty associated with missing a prayer like eternal damnation? (AMI is more robust than call files.)

    The answers would help guide you in deciding if a simple cron based shell script generating call files or a database driven AMI daemon is the best approach.

    In answer to your specific question, the call files need to be “mv’ed”
    into /v/s/a/o/ because:

    ) You need to use mv instead of cp because mv is an ‘atomic’ function*
    meaning it happens all at once so that Asterisk will not try to read an incomplete file.

    ) This is the default value of ‘astspooldir.’ You can specify a different location in asterisk.conf if needed.

    *) Assuming the source and destination are on the same filesystem.

  • Dear Steve;

    Thanks a lot for your help.

    Specifically what I need is the following:

    1) One wave file to be paged at the Phones. In the 5 times, the same file will be used.

    2) Praying time need to be obtained from text (or database). So, it is not always the same time. What actually is needed to be obtained from the text file or the database is the time of the pray for each date (for example, if today is 28 of December so the query will be for this date and then it is required to check if the time is same as the current time to page the wave file on the Phones).

    I have one more question:

    What was u meaning by call file and why it is required to place them in the ‘astspooldir.’?

    Regards Bilal

  • Please don’t top-post. If you don’t know what that means, please consult Google.

    There are 2 methods of originating a call external to Asterisk: call files and the Asterisk Manager Interface (AMI).

    A call file is a text file that you create. The format is very specific. It could contain (in the context of your needs) the phone number to dial and the path of the file to play. A call file is kind of like a ‘message in a bottle.’ You cast it into the sea and hope for the best. When this file is “mv’ed” into the directory specified in the Asterisk astspooldir variable, Asterisk will read it and try to do what you want. You can
    ‘schedule’ a call file to be processed in the future by setting the file’s
    ‘mtime.’

    The Asterisk Manager Interface (AMI) is a TCP connection between your program and Asterisk. You can issue commands (like originate) and receive responses. AMI is more robust because you can make decisions based on the response.

    If robustness is not of primary importance, a script scheduled by cron to run after midnight could create the 5 call files for that day, setting the
    ‘mtime’ of each file before “mv’ing” the file to the directory specified by astspooldir — usually /var/spool/asterisk/outgoing/

    How many customers will be receiving these reminders?

    What religion is this targeted to?

  • Shaun Ruffell wrote:
    I would add that the “rule # 5 was added long after the first 4, by someone in charge after one of the many times this subject has popped up.

    Many of the same complainers routinely do not remove the multi line footers, sometimes MANY of them, forcing those who really want to read a reply to wade through the mess. Seems some can’t be bothered to delete them

    I would also add that rules are made to be broken!

    Peg Leg O’Brien

  • Wow. Didn’t know there was a rule… I never got the whole argument. If the flow is top posting, I top post. If I am certain I can answer a simple question with a simple answer, sometimes I will just top post.

    Totally off topic, apologies. I know I have weighed in once or twice but really never cared. If the flow was totally borked and I didn’t care enough to follow the topic, it wasn’t that important anyways.

    Even more off topic. Can someone smarter than me get the post totals for each year? I was #1 one year. I am not even talking about individual post counts though. It just seems the list has died for the most part.

    Thanks, Steve T

  • * It is required that all the employers at the company to hear this on their IP Phones.

    * Islam.

    * How can I know this format? Because I need to know what should I place in this file so it will execute Paging for this group of Phones?

    * Can you explain for me please?

    I am fully thanks.

    Regards Bilal

    —————-

  • This may help:

    http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out

    In my experience, you can’t just dump xxx call files into the outgoing directory. If you expect more than a dozen or so, you’ll have to move them in blocks as they are processed. Another good reason to use AMI.

    Create a file named fajr containing:

    application: playback
    channel: sip/bilal
    data: fajr-in-10-minutes

    Copy the file to a directory we assume is on the same file system as
    /var/spool/asterisk/outgoing/:

    cp\
    fajr\
    /var/spool/asterisk/tmp/

    Set the file’s ‘mtime’

    touch\
    –date=’now + 2 minutes’\
    –time=mtime\
    /var/spool/asterisk/tmp/fajr

    Move it to the outgoing directory:

    mv\
    /var/spool/asterisk/tmp/fajr\
    /var/spool/asterisk/outgoing/

    Your phone should ring in about 2 minutes.

    You may want to look into setting ‘auto-answer’ or some sort of ‘overhead paging’ with a very discreet sound file like a short, single beep.

    Please consider AMI if you are looking for a robust service.

  • How many people do you plan to page? because if numbers are high (or variable) you may have an easier life by using some sort of dialer…. if numbers are not very high and two lines are enough, our WombatDialer is free to use. l.

    2012/12/29 bilal ghayyad

  • Doesn’t the OP wish to page all phones? So it’s not an issue of dumping dozens of call files all at once.

    Does paging work?

    http://www.voip-info.org/wiki/view/Asterisk+cmd+Page

    http://www.voip-info.org/wiki/view/Asterisk+Paging+and+Intercom

    Overhead paging might also be something to consider, requiring just one call to page “everyone.”

    –Don

    From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Lenz Emilitri Sent: Wednesday, January 02, 2013 5:15 AM
    To: Asterisk Users Mailing List – Non-Commercial Discussion Subject: Re: [asterisk-users] Paging for Praying

    How many people do you plan to page? because if numbers are high (or variable) you may have an easier life by using some sort of dialer…. if numbers are not very high and two lines are enough, our WombatDialer is free to use.

    l.

    2012/12/29 bilal ghayyad

    2) Praying time need to be obtained from text (or database). So, it is not always the same time. What actually is needed to be obtained from the text file or the database is the time of the pray for each date (for example, if today is 28 of December so the query will be for this date and then it is required to check if the time is same as the current time to page the wave file on the Phones).

  • Thanks for the help.

    As I see that the call file is used to generate calls, can I use this technique to page the Phones?

    It is one wave file only that need to be Paged for all the Phones connected on the Asterisk PBX.

    When I say Paging, I mean that they are going to hear the sound from the speaker (without pickup the handset).

    By using AMI, then I can build PHP script that will use the AMI to do the Page?

    Thanks and Regards Bilal

  • Please trim cruft irrelevant to the current questions.

    Yes. The call file would look something like:

    application: page
    data: sip/bilal&sip/steve
    channel: local/fajr@prayer-reminder

    and a snippet of extensions.conf would look something like:

    [prayer-reminder]
    exten = fajr,1, verbose(1,[${EXTEN}@${CONTEXT}])
    exten = fajr,n, playback(time-for-fajr)
    exten = fajr,n, hangup()

    Then you will have to learn how to set the ‘auto-answer’ SIP header for each of your phone types.

    The page at:

    http://www.voip-info.org/wiki/view/Asterisk+cmd+Page

    should help with the specifics of setting auto-answer.

    This also means the ‘data’ line in the call file will change to something like:

    data: local/bilal@page&local/steve@page

    I’m sorry. I thought we had a ‘failure to communicate’ in your use of the word page in your previous emails. I though you meant playback.

    Since you are only placing a single call, the call file approach should be fine. But, to answer your question, you should be able to use AMI as well.

  • Thanks for the help and it seems I deleted some of my emails by mistake ! I am sorry if I repeated my question.

    As I see that the call file is used to generate calls, can I use this technique to page the Phones?

    It is one wave file only that need to be Paged for all the Phones connected on the Asterisk PBX.

    When I say Paging, I mean that they are going to hear the sound from the speaker (without pickup the handset).

    By using AMI, then I can build PHP script that will use the AMI to do the Page?

    Thanks and Regards Bilal

  • Whether you use .call file or AMI, you should still do the call/page using a context and that context run the PHP script.

    —–Original Message—

  • Yes. The call file would look something like:

    application: page
    data: sip/bilal&sip/steve
    channel: local/fajr@prayer-reminder

    (This is in alphabetical order. The ‘leg’ to the channel is executed first.)

    and a snippet of extensions.conf would look something like:

    [prayer-reminder]
    exten = fajr,1, verbose(1,[${EXTEN}@${CONTEXT}])
    exten = fajr,n, playback(time-for-fajr)
    exten = fajr,n, hangup()

    Then you will have to learn how to set the ‘auto-answer’ SIP header for each of your phone types.

    The page at:

    http://www.voip-info.org/wiki/view/Asterisk+cmd+Page

    should help with the specifics of setting auto-answer.

    This also means the ‘data’ line in the call file will change to something like:

    data: local/bilal@page&local/steve@page

    I’m sorry. I think we had a ‘failure to communicate’ in your use of the word ‘page’ in your previous emails. I thought you meant ‘playback.’

    Since you are only placing a single call, the call file approach should be fine. But, to answer your question, you should be able to use AMI as well.