📜 ⬆️ ⬇️

The easiest way to call a list of numbers with Asterisk

Not so long ago, my customer had a need to ring up all his employees with playing a small voice message. I had no desire to install complex systems of mass calls. In the end, I found a very simple way to solve this problem.


The dialer consists of a shell script:

#!/bin/sh # Asterisk call from list script for FreePBX # Based on example at http://asterisk-support.ru/forum/topics/267/ pause=40 spooldir=/astdb/spool # No trailing slash! diallist=/etc/asterisk/scripts/dialer/diallist.txt echo `date`": Dialing with $pause second pause" while read number; do echo "Channel: Local/8$number@prozvon-dialer MaxRetries: 0 RetryTime: 5 WaitTime: 30 Context: prozvon-informer Extension: 2222 Callerid: 2222 Account: autodialer Priority: 1" > $spooldir/tmp/$number chmod 777 $spooldir/tmp/$number chown asterisk:asterisk $spooldir/tmp/$number mv $spooldir/tmp/$number $spooldir/outgoing echo "$number" sleep $pause done < $diallist echo "Done" exit 0 

')
and two contexts - a picker:

 [prozvon-dialer] exten => _8XXXXXXXXXX,1,Dial(SIP/GorodOut/${EXTEN},60) ;  exten => _8XXXXXXXXXX,n,Set(CDR(userfield)=${HASH(SIP_CAUSE,${CDR(dstchannel)})}) ;   exten => _8XXXXXXXXXX,n,Hangup ;  


GorodOut is an account of our SIP-provider.

and dictator

 [prozvon-informer] exten => 2222,1,Answer ;  exten => 2222,n,Wait(3) ; 3  exten => 2222,n,Background(announcement) ;  announcement exten => 2222,n,Hangup ;  


The script, being launched, will pick up the specified text file, in which the numbers on the list simply follow, one number per line. Based on this data, he will create a special call-file and put it in the appropriate directory, from where this file is picked up by asterisk. Learn more about call-files here .

How do we know the results? Very simple:

 SELECT * FROM cdr WHERE accountcode = 'autodialer'; 


Also, in case the dialing fails, the reason for this will be indicated in more detail in the userfield field of the CDR.

And finally:

Article 18. Advertising distributed by telecommunication networks (as amended by Federal Law of 27.10.2008 N 179-)
2. It is not allowed to use telecommunication networks for the dissemination of advertising using the means of selection and (or) dialing a subscriber number without human participation (automatic dialing, automatic distribution).

Source: https://habr.com/ru/post/159503/


All Articles