Call file with Read(response)?

I am using Asterix / FreePBX with a GSM box to send out appointment reminders for multiple companies and wondering, just how much can be scripted in the outbound call file queue? Here is where this is heading. I have this as a call file:

Channel: SIP/4805551234@192.168.1.55
MaxRetries: 5
Callerid: "Joe Smith" <2095551212>
RetryTime: 300
WaitTime: 45
Context: outboundmsg1
Extension: s
Priority: 1

This calls me, plays a message and waits for a response because of the “Context” which looks like this:

[outboundmsg1]
exten => s,1,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
exten => s,2,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
exten => s,3,Answer
exten => s,4,Wait(1)
exten => s,5,Background(outboundmsgs/msg1) ; "play outbound msg"
exten => s,6,Background(outboundmsgs/how_to_ack) ; "Press 1 to replay or 2 to acknowledge receiving this message"
exten => 1,1,Goto(s,5) ; replay message
exten => 2,1,Goto(msgack,s,1) ; acknowledge message
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup

I see I can do a lot of scripting things in the extensions_custom.conf, but in my case I have multiple companies with appointments at 10 minute increments, so about 48 different combinations per company, so it seems better to script that from the outbound call file queue than to keep editing the extensions_custom.conf file.

With that in mind, I have this which using the “Data” attribute allows me to script any audio file, but then the “Context” seems to be ignored.

Channel: SIP/1111
Application: Playback
Context: outboundmsg1
Data: outboundmsgs/msg1
CallerID: Asterisk <(555) 555-1212>

extensions_custom.conf:

[readresponses]
exten => s,1,Set(TIMEOUT(digit)=5)             ; Set Digit Timeout to 5 seconds
exten => s,2,Set(TIMEOUT(response)=10)         ; Set Response Timeout to 10 seconds
exten => s,3,Answer
exten => s,4,Wait(1)
exten => 1,1,Goto(msgack,s,1) ; acknowledge message
### Here I would love to insert a database / http call, or some other way of recording their response
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup

Is there a way using the call files to send variables through to the extensions_custom.conf where you would expect to have more scripting ability, or is there a way in the call file to use the Read() function, and maybe do a little scripting?

Can I use the “Data” variable more than once for example if I wanted to insert an extra part into the playback?

I realize I may be stepping into building an “Application” or maybe using the AGI, if there is a better / simpler way of doing this, I am happy to do so.

Use AMI + DataBase + Local Context and that’s all. A recommendation is to lookup in the forum or Google because appointment “applications” and dialers are a very very very common topic in asterisk.

You can encode the parameters into the extension, rather than always using s.

Also note, that I don’t know how FreePBX works, so I can only talk about extensions.conf.

Thanks, I will look into your suggestion Navaismo. For the first part, I did learn about using variables in the call file, which then was able to select a wav file for playback. Now I am trying to figure out how to read the response and store it. Just for grins I put this together:

call file:

Channel: SIP/4805551234@192.168.1.55
MaxRetries: 5
Callerid: "Joe Smith" <2095551212>
RetryTime: 300
WaitTime: 45
Context: readresponse
SetVar:FILE=outboundmsgs/msg1
Extension: s
Priority: 1

extension_custom.conf

[readresponse]
exten => s,1,Set(TIMEOUT(digit)=5)             ; Set Digit Timeout to 5 seconds
exten => s,2,Set(TIMEOUT(response)=10)         ; Set Response Timeout to 10 seconds
exten => s,3,Answer
exten => s,4,Wait(1)
exten => s,5,Background(${FILE})         ; "play outbound msg"
exten => n,Read(Request,dial,1,i)
exten => n,CURL(http://192.168.1.235/test.php[|${Request}]) ##was just going to check apache logs to see if it made it.
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup

I thought I could use CURL here (https://www.voip-info.org/wiki/view/Asterisk+func+curl), but I was wrong. Is there another one I should read up on? This is what showed up in the console when I hit the number 4:

-- Executing [s@outboundmsg1:3] Answer("SIP/192.168.1.55-00000012", "") in new stack
-- Executing [s@outboundmsg1:4] Wait("SIP/192.168.1.55-00000012", "1") in new stack
   > 0x7fd918013930 -- Probation passed - setting RTP source address to 192.168.1.55:19850
-- Executing [s@outboundmsg1:5] BackGround("SIP/192.168.1.55-00000012", "outboundmsgs/msg1") in new stack
-- <SIP/192.168.1.55-00000012> Playing 'outboundmsgs/msg1.gsm' (language 'en')
[2017-05-19 15:35:59] WARNING[3945][C-00000012]: pbx.c:6888 __ast_pbx_run: Invalid extension '4', but no rule 'i' or 'e' in context 'outboundmsg1'
[2017-05-19 15:35:59] NOTICE[3945]: pbx_spool.c:427 attempt_thread: Call completed to SIP/4805551234@192.168.1.55

You changed from the ‘s’ extension to the ‘n’ extension but without a priority on your Read and CURL lines.

You might want to use the ‘same’ function instead.

[readresponse]
exten => s,1,Set(TIMEOUT(digit)=5)             ; Set Digit Timeout to 5 seconds
 same =>   n,Set(TIMEOUT(response)=10)         ; Set Response Timeout to 10 seconds
 same =>   n,Wait(1)
 same =>   n,Playback(${FILE})         ; "play outbound msg"
 same =>   n,Read(Request,dial,1,i)
 same =>   n,CURL(http://192.168.1.235/test.php[|${Request}]) ##was just going to check apache logs to see if it made it.
exten => t,1,Playback(vm-goodbye)
same =>   n,Hangup()

One minor point, Answer() does nothing here as you can’t answer an outgoing channel, and it is already up before the dialplan is launched.