ID and Tail Msg Recorder via app_rpt

If you got here from a search engine, you “will need” to read the beginning to understand how to use this info by going to http://themidnightengineer.com/category/ham-amateur-radio/app_rpt/m-e-toys-for-app_rpt/m-e-toys-1st-step/

Do not proceed unless you read this in it’s entirety. Make back-up files before editing anything. I offer no support. Use at your own risk.

We shall start with the ivr.conf custom extension file with our toy, recording and selecting between 2 system ID’s and 5 selectable Tail messages, 3 selectable aux msgs via the repeater system:

aux msgs are still just tail messages. I named them differently to separate purpose.

So I can keep ecom messages stored there and turn them into rotation when needed.

There is no dual rotation between them. One at a time based on the “tailmessagelist=” in rpt.conf for both  tmsg and auxmsg.

First, make a directory under /etc/asterisk called “msg”

 /etc/asterisk/msg and change ownership of  directory to 775

Second, edit rpt.conf and under the node stanza, add these lines:

idrecording =/etc/asterisk/msg/idmsg

tailmessagelist=/etc/asterisk/msg/tmsg1,/etc/asterisk/msg/tmsg2,/etc/asterisk/msg/tmsg3,/etc/asterisk/msg/tmsg4,/etc/asterisk/msg/tmsg5,/etc/asterisk/msg/auxmsg1,/etc/asterisk/msg/auxmsg2,/etc/asterisk/msg/auxmsg3 ;tail message list, if not present, will go to next one that is.

Now for the contents of ivr.conf:

[ivrmenu] ;important first line. our *97 cmd example used context  ivrmenu, this brings *97 cmds to this page.

; the beginning menu sorts and routes extensions to a new stanza
; place commands above the readback you don’t want to be read back on the air with one line…

; cmd#,1,Goto( newstanza below the error trap)

; this will be more important when we add other stuff later.

; exten => _X.,1,Noop() ; there must be a 1st instruction if you comment out the readback

exten =>_X.,1,SayAlpha(${EXTEN}) ; Readback Dialed Number

; evaluate the extension route to new stanza
exten => 10,2,Goto(sys-msgs,10,1) ;tmsg1 play
exten => 11,2,Goto(sys-msgs,11,1) ;tmsg1 rec
exten => 12,2,Goto(sys-msgs,12,1) ;tmsg1 off
exten => 13,2,Goto(sys-msgs,13,1) ;tmsg1 on
exten => 20,2,Goto(sys-msgs,20,1) ;tmsg2
exten => 21,2,Goto(sys-msgs,21,1)
exten => 22,2,Goto(sys-msgs,22,1)
exten => 23,2,Goto(sys-msgs,23,1)
exten => 30,2,Goto(sys-msgs,30,1) ;tmsg3
exten => 31,2,Goto(sys-msgs,31,1)
exten => 32,2,Goto(sys-msgs,32,1)
exten => 33,2,Goto(sys-msgs,33,1)
exten => 40,2,Goto(sys-msgs,40,1) ;tmsg4
exten => 41,2,Goto(sys-msgs,41,1)
exten => 42,2,Goto(sys-msgs,42,1)
exten => 43,2,Goto(sys-msgs,43,1)
exten => 50,2,Goto(sys-msgs,50,1) ;tmsg5
exten => 51,2,Goto(sys-msgs,51,1)
exten => 52,2,Goto(sys-msgs,52,1)
exten => 53,2,Goto(sys-msgs,53,1)
exten => 60,2,Goto(sys-msgs,60,1) ;idmsg1 play
exten => 61,2,Goto(sys-msgs,61,1) ;idmsg1 rec
exten => 62,2,Goto(sys-msgs,62,1) ;idmsg2 pl
exten => 63,2,Goto(sys-msgs,63,1) ;idmsg2 rec
exten => 67,2,Goto(sys-msgs,67,1) ;activate id1
exten => 68,2,Goto(sys-msgs,68,1) ;activate id2
exten => 69,2,Goto(sys-msgs,69,1) ;playback active id
exten => 70,2,Goto(sys-msgs,70,1) ;auxmsg1 pl
exten => 71,2,Goto(sys-msgs,71,1) ;auxmsg1 rec
exten => 72,2,Goto(sys-msgs,72,1) ;auxmsg1 off
exten => 73,2,Goto(sys-msgs,73,1) ;auxmsg1 on
exten => 80,2,Goto(sys-msgs,80,1) ;auxmsg2
exten => 81,2,Goto(sys-msgs,81,1)
exten => 82,2,Goto(sys-msgs,82,1)
exten => 83,2,Goto(sys-msgs,83,1)
exten => 90,2,Goto(sys-msgs,90,1) ;auxmsg3
exten => 91,2,Goto(sys-msgs,91,1)
exten => 92,2,Goto(sys-msgs,92,1)
exten => 93,2,Goto(sys-msgs,93,1)
exten => 97,2,Goto(sys-msgs,97,1);turn-off-all-voice msgs except IDmsg

; end of presort/route to new stanza for valid commands

; error trap if extension falls through

exten =_X.,2,Playback(option-is-invalid&silence/1) ;trap for bad#’s
exten =_X.,n,Playback(silence/1&vm-goodbye)
exten =_X.,n,Hangup

;

; the above presorted all commands for msgs to [sys-msgs] (important if we include all the toys later)

;

[sys-msgs] ; keep this stanza at the end of the file
exten => 10,1,Playback(/etc/asterisk/msg/tmsg1.wav)
exten => 10,n,Hangup
exten => 11,1,Playback(please-enter-your&vm-message&after-the-tone)
exten => 11,n,Record(/etc/asterisk/msg/tmsg1:wav)
exten => 12,1,System(mv -f /etc/asterisk/msg/tmsg1.wav /etc/asterisk/msg/tmsg1-off.wav)
exten => 12,2,Playback(message-number&letters/t&digits/1&removed)
exten => 13,1,System(mv -f /etc/asterisk/msg/tmsg1-off.wav /etc/asterisk/msg/tmsg1.wav)
exten => 13,2,Playback(message-number&letters/t&digits/1&restarting)

exten => 20,1,Playback(/etc/asterisk/msg/tmsg2.wav)
exten => 20,n,Hangup
exten => 21,1,Playback(please-enter-your&vm-message&after-the-tone)
exten => 21,n,Record(/etc/asterisk/msg/tmsg2:wav)
exten => 22,1,System(mv -f /etc/asterisk/msg/tmsg1.wav /etc/asterisk/msg/tmsg2-off.wav)
exten => 22,2,Playback(message-number&letters/t&digits/2&removed)
exten => 23,1,System(mv -f /etc/asterisk/msg/tmsg2-off.wav /etc/asterisk/msg/tmsg2.wav)
exten => 23,2,Playback(message-number&letters/t&digits/2&restarting)

exten => 30,1,Playback(/etc/asterisk/msg/tmsg3.wav)
exten => 30,n,Hangup
exten => 31,1,Playback(please-enter-your&vm-message&after-the-tone)
exten => 31,n,Record(/etc/asterisk/msg/tmsg3:wav)
exten => 32,1,System(mv -f /etc/asterisk/msg/tmsg3.wav /etc/asterisk/msg/tmsg3-off.wav)
exten => 32,2,Playback(message-number&letters/t&digits/3&removed)
exten => 33,1,System(mv -f /etc/asterisk/msg/tmsg3-off.wav /etc/asterisk/msg/tmsg3.wav)
exten => 33,2,Playback(message-number&letters/t&digits/3&restarting)

exten => 40,1,Playback(/etc/asterisk/msg/tmsg4.wav)
exten => 40,n,Hangup
exten => 41,1,Playback(please-enter-your&vm-message&after-the-tone)
exten => 41,n,Record(/etc/asterisk/msg/tmsg4:wav)
exten => 42,1,System(mv -f /etc/asterisk/msg/tmsg4.wav /etc/asterisk/msg/tmsg4-off.wav)
exten => 42,2,Playback(message-number&letters/t&digits/4&removed)
exten => 43,1,System(mv -f /etc/asterisk/msg/tmsg4-off.wav /etc/asterisk/msg/tmsg4.wav)
exten => 43,2,Playback(message-number&letters/t&digits/4&restarting)

exten => 50,1,Playback(/etc/asterisk/msg/tmsg5.wav)
exten => 50,n,Hangup
exten => 51,1,Playback(please-enter-your&vm-message&after-the-tone)
exten => 51,n,Record(/etc/asterisk/msg/tmsg5:wav)
exten => 52,1,System(mv -f /etc/asterisk/msg/tmsg5.wav /etc/asterisk/msg/tmsg5-off.wav)
exten => 52,2,Playback(message-number&letters/t&digits/5&removed)
exten => 53,1,System(mv -f /etc/asterisk/msg/tmsg5-off.wav /etc/asterisk/msg/tmsg5.wav)
exten => 53,2,Playback(message-number&letters/t&digits/5&restarting)

exten => 60,1,Playback(letters/i&letters/d&vm-message&digits/1)
exten => 60,n,Playback(/etc/asterisk/msg/idmsg1.wav)
exten => 60,n,Hangup
exten => 61,1,Playback(please-enter-your&letters/i&letters/d&vm-message&digits/1&after-the-tone&silence/3)
exten => 61,n,Record(/etc/asterisk/msg/idmsg1:wav)

exten => 62,1,Playback(letters/i&letters/d&vm-message&digits/2)
exten => 62,n,Playback(/etc/asterisk/msg/idmsg2)
exten => 62,n,Hangup
exten => 63,1,Playback(please-enter-your&letters/i&letters/d&vm-message&digits/2&after-the-tone&silence/3)
exten => 63,n,Record(/etc/asterisk/msg/idmsg2:wav)

exten => 67,1,Playback(letters/i&letters/d&vm-message&digits/1&activated&silence/2)
exten => 67,n,System(cp -f /etc/asterisk/msg/idmsg1.wav /etc/asterisk/msg/idmsg.wav)

exten => 68,1,Playback(letters/i&letters/d&vm-message&digits/2&activated)
exten => 68,n,System(cp -f /etc/asterisk/msg/idmsg2.wav /etc/asterisk/msg/idmsg.wav)

exten => 69,1,Playback(activated&letters/i&letters/d)
exten => 69,n,Playback(/etc/asterisk/msg/idmsg)
exten => 69,n,Hangup

exten => 70,1,Playback(/etc/asterisk/msg/auxmsg1.wav)
exten => 70,n,Hangup
exten => 71,1,Playback(please-enter-your&vm-message&after-the-tone)
exten => 71,n,Record(/etc/asterisk/msg/auxmsg1:wav)
exten => 72,1,System(mv -f /etc/asterisk/msg/auxmsg1.wav /etc/asterisk/msg/auxmsg1-off.wav)
exten => 72,2,Playback(message-number&letters/a&digits/1&removed)
exten => 73,1,System(mv -f /etc/asterisk/msg/auxmsg1-off.wav /etc/asterisk/msg/auxmsg1.wav)
exten => 73,2,Playback(message-number&letters/a&digits/1&restarting)

exten => 80,1,Playback(/etc/asterisk/msg/auxmsg2.wav)
exten => 80,n,Hangup
exten => 81,1,Playback(please-enter-your&vm-message&after-the-tone)
exten => 81,n,Record(/etc/asterisk/msg/auxmsg2:wav)
exten => 82,1,System(mv -f /etc/asterisk/msg/auxmsg2.wav /etc/asterisk/msg/auxmsg2-off.wav)
exten => 82,2,Playback(message-number&letters/a&digits/2&removed)
exten => 83,1,System(mv -f /etc/asterisk/msg/auxmsg2-off.wav /etc/asterisk/msg/auxmsg2.wav)
exten => 83,2,Playback(message-number&letters/a&digits/2&restarting)

exten => 90,1,Playback(/etc/asterisk/msg/auxmsg3.wav)
exten => 90,n,Hangup
exten => 91,1,Playback(please-enter-your&vm-message&after-the-tone)
exten => 91,n,Record(/etc/asterisk/msg/auxmsg3:wav)
exten => 92,1,System(mv -f /etc/asterisk/msg/auxmsg3.wav /etc/asterisk/msg/auxmsg3-off.wav)
exten => 92,2,Playback(message-number&letters/a&digits/3&removed)
exten => 93,1,System(mv -f /etc/asterisk/msg/auxmsg3-off.wav /etc/asterisk/msg/auxmsg3.wav)
exten => 93,2,Playback(message-number&letters/a&digits/1&restarting)

exten => 97,1,Playback(message-number&all&removed); not idmsg
exten => 97,n,System(mv -f /etc/asterisk/msg/tmsg1.wav /etc/asterisk/msg/tmsg1-off.wav)
exten => 97,n,System(mv -f /etc/asterisk/msg/tmsg1.wav /etc/asterisk/msg/tmsg2-off.wav)
exten => 97,n,System(mv -f /etc/asterisk/msg/tmsg3.wav /etc/asterisk/msg/tmsg3-off.wav)
exten => 97,n,System(mv -f /etc/asterisk/msg/tmsg4.wav /etc/asterisk/msg/tmsg4-off.wav)
exten => 97,n,System(mv -f /etc/asterisk/msg/tmsg5.wav /etc/asterisk/msg/tmsg5-off.wav)
;exten => 97,n,System(mv -f /etc/asterisk/msg/idmsg.wav /etc/asterisk/msg/idmsg-off.wav)
exten => 97,n,System(mv -f /etc/asterisk/msg/auxmsg1.wav /etc/asterisk/msg/auxmsg1-off.wav)
exten => 97,n,System(mv -f /etc/asterisk/msg/auxmsg2.wav /etc/asterisk/msg/auxmsg2-off.wav)
exten => 97,n,System(mv -f /etc/asterisk/msg/auxmsg3.wav /etc/asterisk/msg/auxmsg3-off.wav)

Some of this structure may not make sense at this point in time but as long as you can see how we are doing it all, you may have better ideas. If you are not fair working with asterisk, just use it the way I have laid it out. Some of the weird structure is because we will be adding things as we go along. Some may not be posted for some time…

Most important first step is record idmsg1 (*97 61) and set it active ( *97 67) 

So the way this part works is (how to use):

Tail messages rotate whatever msgs in the list from above that are present. If not present, they are skipped. When you deactivate a msg (off), it renames it xxxx-off.wav so it will not be seen by the list and not played. When you reactivate that msg, it renames it back to the original filename. I will say that recording works best from a pc using iaxrpt or a sip phone and a good mic.

*9711 will record a tail msg #1 named tmsg1.wav in the diectory /etc/asterisk/msg/

when finished, you need to exit, you will need to patch-hang-up  ” *0 ”

*9710 will playback the tmsg1 we just recorded. You do not need to activate a tail or aux msg unless you have deactivated it and now want it to play.

Test it all out and record all of your messages. Much easier than audicity.

Format of command: (to make easy to remember)

*97 (ivr) 1/2/3/4/5/6/7/8/9 (msg#) 0/1/2/3 (play, rec, off, on )

*97 97 will deactivate all t-msg and aux-msgs.

You can not deactivate voice id. You can change from recorded idmsg1 to idmsg2 or back.

After recording a idmsg 1 & 2, you need to manually select which one is to be used for id or you will not have a voice id and the cw id will not run when id has been set to voice (except cwid at id-over-activity) When you select id-msg#, you are making a copy of the file selected and naming it “idmsg.wav” which is what our settings are in rpt.conf

I would suggest you do not change the script until you make it run once and you fully understand asterisk dialplan rules. I am sure someone can make a much better script than I once they have realized how I got app_rpt to do some functions on asterisk that app_rpt has control of.

However, it is possible to macro/script a method to change id’s from idmsg1/idmsg2 using the scheduler for flexability. Sorry, not going there on this page. Just giving you the idea. But you now have assignable commands for macro/sched to work.

So, a short story as how I might use this: While at any time, there may be various tmsgs on and I don’t want to find out what is on and off when a ecom event happens. I would use *97 97 to turn them all off and then select one of the auxmsgs to be turned on that I have stored as ecom msgs.

If you have ssh or ftp access, you can look in /etc/asterisk/msg/ for those tmsgs or auxmsg that are turned off.

They will show that in their filename  ex: tmsg5-off.wav

Other notes:

My advise to most of you is to reduce the number of tail msgs to 3 and aux msgs to 1 or 2 and reduce the tailmessagetime to 720,000. You can do this in tailmessagelist without changing the code above. It should be plenty. When a tmsg is off, it is skipped but you will not get a new tail message to speak until the timer has elapsed again and a message is found that is on.  So if you only have one of 8 active, it could be quite a while before one of them is actually spoken. Sorry, that is hard wired in app_rpt. Adjust all of this to suite you needs based on how many active tail messages you will generally have on and how many is in your list. Set timer appropriately.

A more likely good scenario is to have only 3 tmsgs recorded and in the list and select only one of them per day/hour/week and changed by sched/macro as needed. For this I would use a timer of about 5 min. So the one would play every 15 min. Just an example.

This is all slightly crude but it works.

My timers/settings:

(5 active tail msgs)

tailmessagetime=9000000 ; 15 minutes between tail messages
tailsquashedtime=240000 ; If squashed by another user, try again after 4 min

idtime=600000 ; in 10ms = 10 min
politeid=500000 ;8m20s
sleeptime=1830 ;in seconds 300=5min

holdofftelem=1