Dialplan, read rows from textfile, then continue

Hi,

First, I’m new to Asterisk/dialplans etc so bear with me.

I have a webpage with checkboxes which triggers a perl script when submitted. The perl script then generates a textfile based on the checkbox values. The purpose of this is to generate a series of soundfiles to be played when someone calls. The order and number of these soundfiles can vary depending on the choices on the webpage.

Here’s an example of what the textfile can look like (the way it’s formatted right now):

[quote]exten => s,n,Playback(awav1)
exten => s,n,Playback(pa)
exten => s,n,Playback(20)
exten => s,n,Playback(i)
exten => s,n,Playback(1)
exten => s,n,Playback(2)
exten => s,n,Playback(4)
exten => s,n,Playback(awav2)[/quote]
I want the normal dialplan to read the rows from this file so it plays the sounds listed in the textfile and the continue on as normal (or just continue if all the checkboxes are empty and the script generated an empty file). Lets say the current dialplan looks like this:

[quote]exten => s,1,Answer
exten => s,n,Playback(tt-weasels)
exten => s,n,Hangup[/quote]
I want to change it to this:

[quote]exten => s,1,Answer
Read rows from textfile here!
exten => s,n,Playback(tt-weasels)
exten => s,n,Hangup[/quote]

Can this be done? If so, how?
If not, any suggestions on how to do it?

This way it won’t work.

But the good news comes here:

You may reach Your goal by using AGI which than just interprets the content from Your webservice and does the things You want it to do (eg Playbacks).

Another approach may be the following:
Let the webpage store the result of the checkboxes in one line each checkbox-value separated from each other by a specific character. To stay in Your exmaple this may be:

(No carriage return / line feed at the end of the list!)
We assume for the code snippet the filename of this file to be /etc/asterisk/list.txt.

In Your dialplan You may then do something like this

exten => s,1,Answer
exten => s,n,Set(result=${SHELL(test -f /etc/asterisk/list.txt && echo -n 1 || echo -n 0)})
exten => s,n,GotoIf($[${result}=1]?play:continue)
exten => s,n(play),Set(foo=${FILE(/etc/asterisk/list.txt)})
exten => s,n,MSet(x=$[0])
exten => s,n(next),GotoIf($[ ${x}<${FIELDQTY(foo,\;)}]?playfile:continue)
exten => s,n(payfile),Playback(${CUT(foo,;,$[${x}+1])})
exten => s,n,MSet(x=$[${x}+1])
exten => s,n,Goto(next)
exten => s,n(continue),Playback(tt-weasels)
exten => s,n,Hangup

Hi thanks for the reply.
Will try your second alternative

[quote=“abw1oim”]This way it won’t work.

But the good news comes here:

You may reach Your goal by using AGI which than just interprets the content from Your webservice and does the things You want it to do (eg Playbacks).

Another approach may be the following:
Let the webpage store the result of the checkboxes in one line each checkbox-value separated from each other by a specific character. To stay in Your exmaple this may be:

(No carriage return / line feed at the end of the list!)
We assume for the code snippet the filename of this file to be /etc/asterisk/list.txt.

In Your dialplan You may then do something like this

exten => s,1,Answer exten => s,n,Set(result=${SHELL(test -f /etc/asterisk/list.txt && echo -n 1 || echo -n 0)}) exten => s,n,GotoIf($[${result}=1]?play:continue) exten => s,n(play),Set(foo=${FILE(/etc/asterisk/list.txt)}) exten => s,n,MSet(x=$[0]) exten => s,n(next),GotoIf($[ ${x}<${FIELDQTY(foo,\;)}]?playfile:continue) exten => s,n(payfile),Playback(${CUT(foo,;,$[${x}+1])}) exten => s,n,MSet(x=$[${x}+1]) exten => s,n,Goto(next) exten => s,n(continue),Playback(tt-weasels) exten => s,n,Hangup [/quote]

Hi!

Tested it and it works! Just had to add a \ before the delimiter in cut
exten => s,n(payfile),Playback(${CUT(foo,;,$[${x}+1])})
instead of
exten => s,n(payfile),Playback(${CUT(foo,;,$[${x}+1])})

Thanks for the help!