Using Asterisk or AsteriskNOW to make an auto-dialer for test


#1

Hello,

I’am try de create an autodialer to test some features of a voicemail for my client.
I really know nothing about asterisk but the documentation let me thinking that’s maybe a solution to me.
So i would do this things :

  • Make a call to a mobile phone
  • Waiting for the voicemail
  • Broadcast a voice file (.wav)
  • Hangout

Do you think its possible ?
If yes, how ?

PS : Sorry, i’am french, i have a pretty poor english :wink:


#2

Just look into call files. http://www.voip-info.org/wiki/view/Asterisk+auto-dial+out . Using the AT() command when generating the call files you can schedule the execution of the call files. For auto dialing you can use two Asterisk servers and let one server make calls to other.

You can’t generate a call file in the /var/spool/asterisk/outgoing directory because Asterisk is kind of aggressive with grabbing anything that is placed into this directory and there is a real chance that the file will be processed before finished and ready to proces. You have to generate it using another directory and, when finished, move (not copy) it to /var/spool/asterisk/outgoing.

This is an example on how to generate and execute a call file with Asterisk script but there are a thousand ways to do this.
; with just one “>” the file is created.
exten => s,n,System(echo -E “Channel: SIP/31208080652/04*${LEG}#” > ${PAD})

; with two “>>” a line is added to the file
exten => s,n,System(echo -E “MaxRetries: 0” >> ${PAD})
exten => s,n,System(echo -E “RetryTime: 4000” >> ${PAD})
exten => s,n,System(echo -E “WaitTime: 3600” >> ${PAD})
exten => s,n,System(echo -E “Context: gtalk_conference” >> ${PAD})
exten => s,n,System(echo -E “Extension: s” >> ${PAD})
exten => s,n,System(echo -E “SetVar: LEG=${LEG}” >> ${PAD})
exten => s,n,System(echo -E “SetVar: TIMEOUT(absolute)=600)” >> ${PAD})
exten => s,n,System(echo -E “SetVar: IM_ACCOUNT=${IM_ACCOUNT}” >> ${PAD})
exten => s,n,System(echo -E “SetVar: KLANT_NUMMER=${KLANT_NUMMER}” >> ${PAD})
exten => s,n,System(echo -E “SetVar: ROOM=${ROOM}” >> ${PAD})
exten => s,n,System(echo -E “SetVar: OUTBOUND=${LEG}” >> ${PAD})
exten => s,n,System(echo -E “Priority: 1” >> ${PAD})
;exten => s,n,System(echo -E “SetVar: ROOM=${ROOM:2}” >> ${PAD})

; this line assures that there is a return at the end of the last line
exten => s,n,System(echo -E " " >> ${PAD})

this line makes a .bak file of the just generated call file. Not really needed but very handsome when used for testing
exten => s,n,System(echo cp ${PAD} ${PAD}.bak|at now+ 0 minutes)

this is where the action starts. With changing 0 in some other positive number you will schedule the execution of the call file (actually you are scheduling moving the call file to /var/spool/asterisk/outgoing. I’m not sure but I guess at also has a second option
exten => s,n,System(echo mv ${PAD} /var/spool/asterisk/outgoing/|at now+ 0 minutes)


#3

I’m going to recommend the documentation in the official wiki over voip-info here.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files

Note the last line where it talks about how asterisk will ignore files with a future modification date? That means you can use the Touch command to set the date of the file in the future when asterisk will run it instead of using ‘at’

Also I’d recommend using the FILE function instead of all of those system calls to write the file out, Much cheaper in terms of CPU use.

https://wiki.asterisk.org/wiki/display/AST/Function_FILE


#4

I didn’t know about a file() function but I totally agree (after reading the documentation) that file() might be a better way to write files. I have used System() to generate lots of call files in a short time and it worked like a sharm without any problem. Although a search on “CPU load System() Asterisk” doesn’t give any information about what CPU load System() generates it does sound logical that it is CPU intensive.


#5

when System() is called it causes the PBX to fork a new process, specifically /bin/sh and then /bin/sh has to fork whatever command you give it.

The FILE() function is internal to asterisk and does not have to spawn additional processes to do it’s work.

I will use the FILE function to create my file and then use SYSTEM to modify the date on it if needed and move it into the spool.

One last tip, In your call file you can add the Archive setting to your call files and Asterisk will move them after running them so you don’t have to back them up like you did above.


#6

Thanks a lot for all your responses.

I see now how to make a call file.

Actually I simply not understand how to do a call from asterisk to a public location (on the PSTN). Maybe i’ve miss something in the documentation.


#7

How are you interfacing with the PSTN?

IAX2 trunk, SIP Trunk. Analog Card, PRI?

Really it’s the same as dialing a sip peer, you call the Dial application with the technology you are using and the resource needed followed by the number to dial.