Record multiple greetings without extensions?

I would like to have a single inbound route which would allow users to enter an account number, then prompt them to record their greeting followed by #, then save each one to a different folder. So for instance customer 43223 calls in, enters their number, records their greetings and lets them hear it, re record / accept it.

[inbound-record]
exten => s,1,Set(TIMEOUT(digit)=5)  
exten => s,n,Set(TIMEOUT(response)=15)   
exten => s,n,Read(ACCOUNTNUM,5,i)
exten => s,n,AGI(createDirectory.agi,${ACCOUNTNUM})
exten => s,1,Wait(1)
exten => s,n,Playback(vm-record-prepend)
exten => s,n,Record(43223/tmp_greeting:wav)
exten => s,n,Wait(2)
exten => s,n,Playback(43223/tmp_greeting)

exten => s,n,Playback(press)
exten => s,n,Playback(digits/1)
exten => s,n,Playback(to-accept-recording)
exten => s,n,Playback(press)
exten => s,n,Playback(digits/2)
exten => s,n,Playback(cancel)

exten=> 1,1,AGI(saveFile.agi,${ACCOUNTNUM})
exten=> 2,1,Goto(inbound-record,s,1)

exten => s,n,wait(2)
exten => s,n,Hangup

The createDirectory.agi script should look something like this:

#!/usr/bin/php -q
<?php
$ACCOUNTNUM= $argv[1];
shell_exec("mkdir /var/asterisk/sounds/customers/" . $ACCOUNTNUM);
?>

The saveFile.agi script should look something like this:

#!/usr/bin/php -q
<?php
$ACCOUNTNUM= $argv[1];
shell_exec("mv /var/asterisk/sounds/customers/" . $ACCOUNTNUM. "/tmp_greeting /var/asterisk/sounds/customers/" . $ACCOUNTNUM. "/greeting");
?>

I can’t figure out though how to route the incoming calls from outside in. I got this basic one to work on internal calls, but I don’t know where to put it for external calls to work.

[from-internal-custom]		
exten => 1234,1,Wait(2)
exten => 1234,2,Record(outboundmsgs/msg4:wav)
exten => 1234,3,Wait(2)
exten => 1234,4,Playback(outboundmsgs/msg4)
exten => 1234,5,wait(2)
exten => 1234,6,Hangup
include => agentlogin
include => conferences
include => calendar-event
include => weather-wakeup

AGI is overkill. Shell directly.

You have two priority 1’s for extension s.

You put in in the context associated with the incoming device or line, with the extension that is received as the DID digits,normally s.

1 Like

Thanks David, Good catch on the second priority 1. I am glad to know I can do a shell command directly, I am still learning how is possible going through the manual.

As far as getting that dialplan context to activate, on my incoming route, when it was an internal call it was easy as I just set the incoming route destination to an extension of 1234, but that isn’t working for outside calls coming in.

Setting incoming route destinations sounds like a GUI thing. We don’t support GUIs here as they tend to come with massive dialplans that need to be understood, in addition to understanding how the graphical interface maps into the actual configuration files.

I am not sure why we are talking about it being a GUI thing, it was supposed to be fully automated attendant style where it would all be phone based. I could have users send me MP3’s that get converted, but I like the sound quality of what is captured straight from the phone. I am out of town for the next week but can look at again when I get back.

We are talking GUIs because “route destination” is not a concept known to Asterisk. As far as Asterisk is concerned, there is no real difference between calls originating internally and calls originating externally with DID digits.

1 Like

Just in case anyone else wanted to do this, here is what I used. It could be integrated into an IVR, for me it was just an inbound trunk. Polish it up with a better sequence of audio files to play back, or record your own instructions, this is bare bones.

In the sip_additional.conf:

[11] ; This is a trunk
username=11
secret=******
host=dynamic
type=friend
context=inbound-record
sendrpid=yes
trustrpid=yes

Then in extensions_custom.conf:


[inbound-record]
exten => _.,1,Answer()
exten => _.,n,Set(TIMEOUT(digit)=5)  
exten => _.,n,Set(TIMEOUT(response)=15)  
exten => _.,n,Playback(press)
exten => _.,n,Playback(account_number)
exten => _.,n,Read(ACCOUNTNUM)
exten => _.,n,Playback(pin_number)
exten => _.,n,Read(PINNUM)
exten => _.,n,Set(CURL_RESULT=${CURL(http://www.yourdomain.com/api/?phone=${ACCOUNTNUM}&pin=${PINNUM})})
exten => _.,n,GotoIf($["${CURL_RESULT}" = "false"]?wrong-password,s,1) ; wrong pin, notify them and start over
exten => _.,n,System(/usr/bin/mkdir /var/lib/asterisk/sounds/outboundmsgs/${ACCOUNTNUM}) ; create the directory to save into
exten => _.,n,Playback(vm-record-prepend)
exten => _.,n,Record(/var/lib/asterisk/sounds/outboundmsgs/${ACCOUNTNUM}/tmp_greeting:alaw)
exten => _.,n,Wait(1)
exten => _.,n,Playback(/var/lib/asterisk/sounds/outboundmsgs/${ACCOUNTNUM}/tmp_greeting)
exten => _.,n,Playback(to-accept-recording) ; here you could introduce branching to re-record / save recording
exten => _.,n,Hangup

[wrong-password]
exten => _.,1,Playback(wrong-try-again-smarty)
exten => _.,n,Goto(inbound-record,s,1)