Set dial maximum time and play warning audio
The topic of this post is to show how you can use the Dial cmd option in the dialplan
to limit the duration of a call and tell caller/callee that call is about to finish.
To do this, you can use the L option in your dialplan.
L(x[:y][:z]) - Limit the call to ‘x’ ms. Play a warning when ‘y’ ms are
left. Repeat the warning every ‘z’ ms. The following special
variables can be used with this option:
* LIMIT_PLAYAUDIO_CALLER yes|no (default yes)
Play sounds to the caller.
* LIMIT_PLAYAUDIO_CALLEE yes|no
Play sounds to the callee.
* LIMIT_TIMEOUT_FILE File to play when time is up.
* LIMIT_CONNECT_FILE File to play when call begins.
* LIMIT_WARNING_FILE File to play as warning if ‘y’ is defined.
The default is to say the time remaining.
Example :
If you want to set a maximum of 10 minutes conversation and atone minute before the end, tell both the caller and the callee that the call is about to be drop :
exten => 5140000000,1,Set(LIMIT_PLAYAUDIO_CALLER=yes)
exten => 5140000000,n,Set(LIMIT_PLAYAUDIO_CALLEE=yes)
exten => 5140000000,n,Set(LIMIT_WARNING_FILE=call-about-to-drop)
exten => 5140000000,n,Dial(${EXTEN},30,L(600000:60000))
exten => 5140000000,n,Hangup
So, after 9 minutes of conversation, the caller and the callee will hear call-about-to-drop audio file.
Quick packages install on CentOs 5 and Asterisk 1.4.X
Here is a quick trick on centos/redhat or any yum powered platform
to install all packages that you may need to install asterisk.
It will even install mysql for you as well as odbc connector.
yum -y install gcc gcc-c++ kernel-devel bison openssl-devel \
libtermcap-devel ncurses-devel doxygen curl-devel newt-devel \
mlocate lynx tar wget nmap bzip2 mod_ssl crontabs vixie-cron \
speex speex-devel unixODBC unixODBC-devel libtool-ltdl \
libtool-ltdl-devel mysql-connector-odbc mysql mysql-devel \
mysql-server php-mysql php-mbstring php-mcrypt flex screen
asterisk/zaptel/dahdi/you do not appear to have the sources
When installing asterisk and the zaptel or dahdi module, you may reach the error:
You do not appear to have the sources for <your-kernel-version>
Here, I will explain exactly what asterisk is looking for and how you can fix it.
First, you may really need to install the kernel sources. The headers are needed to compile zaptel/dahdi.
If you use yum, you can install from repository.
yum -y install kernel-devel
If you run SMP kernel, use instead
yum -y install kernel-smp-devel
Here is what zaptel/dahdi will do to determine if you have the kernel source or not :
- find your kernel version by running uname -r and stock it into $(KVERS)
- set variable $(KSRC) to one of the following /lib/modules/$(KVERS)/build or /usr/src/linux or /usr/src/linux-2.4. The Makefile will then check if one of those directories exist.
- The $(KSRC) directory should contain the .config file.
If you installed the kernel sources, you should have the .config file somewhere in /usr/src/kernels/(somedir)
You just then have to create a symbolic link from /usr/src/linux or /lib/modules/$(KVERS)/build to that directory.
Reconfigure, recompile zaptel/dahdi and asterisk.
Hope it helps
Asterisk : Open big log file
When you enable asterisk logs, specifially full logs with DEBUG,
your log file could increase quickly. Open it with vi can use a lot of memory of your server
and prevent you to receive a lot of calls.
You can use split command line to split your file to smaller one
split full
Asterisk automatic dialing
Sometimes, you may need asterisk to call somebody and play any kind of application or run a dialplan extension.
Asterisk call files can be use here. You need to create a call file (which is a clear text file) and move it in /var/spool/asterisk/outgoing/ directory. A thread on the asterisk server will check for new files there and process them.
The file contains keys and values seperated by a ‘:’ character on each line. Here are the accepted parameters:
- Specify where and how to call
- Channel: <channel>: Channel to use for the outbound call
- CallerID: Name <number> Caller ID, please note that it may not work if you do not respect the format: CallerID: Some Name <1234>
- MaxRetries: <number> Number of retries before failing (not including the initial attempt, e.g. 0 = total of 1 attempt to make the call)
- RetryTime: <number> Seconds between retries, don’t hammer an unavailable phone
- WaitTime: <number> Seconds to wait for an answer
- Account: Set the account code to use.
- If the call answers, connect it here
- Context: <context-name> Context in extensions.conf
- Extension: <ext> Extension definition in extensions.conf
- Priority: <priority> Priority of extension to start with
- Set: Set a variable for use in the extension logic (example: file1=/tmp/to ); in Asterisk 1.0.x use ‘SetVar’ instead of ‘Set’
- Application: Asterisk Application to run (use instead of specifiying context, extension and priority)
- Data: The options to be passed to application
- New (?) in Asterisk 1.4
- Set: Can now also write to dialplan functions like CDR()
- AlwaysDelete: Yes/No - If the file’s modification time is in the future, the call file will not be deleted
- Archive: Yes/No - Move to subdir “outgoing_done” with “Status: value”, where value can be Completed, Expired or Failed.
Example :
If you want to call the number 5140000000 through channel Zap/g1 and play welcome prompt when answered, your call file will look like :
Channel: Zap/g1/5140000000
CallerID: Ruddy Micnes <5143161470>
WaitTime: 30
Application: Playback
Data: welcome
Tip : Restrict call by matching caller id
This quick tip will show you how, in asterisk dialplan, you can restrict calls to a specific match of caller id.
Usually, in a dialplan, extensions will match the called number. Like in the following example :
[default]
exten => _514XXXXXXX,1,Noop( CALLS TO NUMBER ${EXTEN} FROM ${CALLERID(all)} )
exten => _514XXXXXXX,n,Dial(Zap/g1/${EXTEN})
This means that anyone that reach an extension starting with 514 and followed by 10 digits will be send to Zap/g1
If you want this extension to be restrict to a specific caller id or match also a caller id pattern (eg: starting with 418 and followed by 10 digits, your dialplan should be like
[default]
exten => _514XXXXXXX/_418XXXXXXX,1,Noop( CALLS TO NUMBER ${EXTEN} FROM ${CALLERID(all)} )
exten => _514XXXXXXX/_418XXXXXXX,n,Dial(Zap/g1/${EXTEN})
Asterisk CDR log all calls
You may have notice that some calls that you are sure that you placed are missing in the CDR file or table.
Those calls may be those that wasn’t answered.
For example, if you place, from one channel, multiple simulatanous or successive calls to differents destinations, you will see only one record : the origination channel tring to reach the destination that answered.
To change this and log all channels even to answered, you need to edit cdr.conf file and add unanswered option .
vi /etc/asterisk/cdr.conf
[general]
unanswered=yes
Unload asterisk server - Batch save cdr
Hi All,
This chronicle will be use to give you tips where you can unload your asterisk server and make him do what he is suppose to do : Take calls.
One departement were you can save processing is CDR logging and database writing.
By default, asterisk will write or post your call detail record (CDR) at the end of every calls. This help keeping track of all calls including bill seconds. But if you have too many calls, the load of your server writing CDR or inserting in the database can become enormous.
You can add some options in /etc/asterisk/cdr.conf. For example, asterisk can just collect the cdr and after 10 calls ou 5 minutes, write the call details in a file or insert them in the database.
Here are options that will help you doing so:
vi /etc/asterisk/cdr.conf
[general]
batch=yes
size=100
time=300
scheduleronly=no
safeshutdown=yes
!!! WARNING (PLEASE READ) !!!
You need to know exactly what every parameter means here and need to tune in those parameters to fit your environment or type of business.
- batch = yes. This means that asterisk will keep CDRs for x seconds (see parameter size and time) and post them all at once. This also means that if your asterisk server crash, or if you manually kills it (kill -9 asterisk) you will loose every CDR in memory. So, if CDRs are very critical for your business and your asterisk server trends to crash sometime, you may consider not enabling this feature. But, if you want to easy loads on asterisk and databases, you can do it. However, you can reduce how many CDR you may lost in case of crash but using ’size’ and ‘time’ parameters.
- size = 100. This means that, at any time, if the number of CDR kept in memory reach 100, they will be post or send in the database.
- time = 300. This means that, every single 300 seconds (5 minutes), the CDR will be post whatever the size is.
- scheduleronly=no. Asterisk has one thread (a kind of separate internal process) whose only job will be to post CDR when comes the time to do so or when the size is reach. If set to ‘no’, everytime the size will be reach, asterisk will start a new thread to post your CDR. If set to ‘yes’, only one still active thread will do the job again and again. Why is this important ? If you set it to ‘yes’ and the same thread is responsible of doing the same job, if you have any kind of delay while posting CDR, the following CDR will be block until the previous are done. That’s why I recommand one separate thread every time specially if your size is big.
-safeshutdown=yes. When you run ‘asterisk> stop now’ in asterisk cli, if this option is set to ‘yes’, asterisk will issue the last CDR post before shutting down, if not, your still-in-memory-CDR may be lost. So, keep this to yes unless CDRs are not very relevant in your business.
Asterisk 1.4.22 and 1.6.0 released
Great news today for the release of those two version that fix many bugs out there.
Please visit http://www.asterisk.org/node/48539
Register to canadian do not call list
A major developement in canadian telemareting environment is about to come on September 30.
For people you want to register to such a list, here is the “How to”
Key facts for consumers
Date Modified: 2008-08-29
The National Do Not Call List (DNCL) will launch on September 30, 2008. It is designed to reduce the number of unwanted telemarketing calls and faxes Canadians receive.
1. How to register?
- As of September 30, 2008, you can register your home phone, cellular or fax number(s) on the National DNCL.
- Signing up is simple, quick and free. You can sign up online at www.LNNTE-DNCL.gc.ca or by calling the toll-free numbers 1-866-580-DNCL (1-866-580-3625) or 1-888-DNCL-TTY (1-888-362-5889).
- Once you have signed up, many telemarketers can no longer call you starting 31 days after your registration.
- You must renew your registration every three years if you want your number(s) to stay on the National DNCL.
2. Who can still call you?
- Registering on the National DNCL will reduce but not eliminate all telemarketing calls and faxes.
- There are certain kinds of telemarketing calls and faxes that are exempt from the National DNCL, including those made by or on behalf of:
- registered charities seeking donations
- newspapers looking for subscriptions
- political parties and their candidates, and
- companies with whom you have an existing commercial relationship; for example, if you have done business with a company in the previous 18 months––such as a carpet-cleaning company––that company can call you.
- Telemarketers making exempt calls must maintain their own do not call lists. If you do not want to be called by these telemarketers, you can ask to be put on their do not call lists. They are obliged to do so within 31 days.
- For more information, see Part II of the Unsolicited Telecommunications Rules and the Telecommunications Act.
3. Market research, polls and surveys
- You will continue to receive calls from organizations conducting market research, polls or surveys even though you are registered on the National DNCL. These are not considered telemarketing calls because they are not selling a product or service, or requesting donations.
4. Rules telemarketers must follow when they call
- Among other things, telemarketers must:
- identify who they are and, upon request, provide you with a fax or telephone number where you can speak to someone about the telemarketing call
- display the telephone number that they are calling from or that you can call to reach them, and
- only call or send faxes between 9:00 a.m. and 9:30 p.m. on weekdays and between 10:00 a.m. and 6:00 p.m. on weekends.
- Telemarketers must not use Automatic Dialing and Announcing Device (devices that dial telephone numbers automatically and deliver a pre-recorded message). However, these devices can be used by police and fire departments, schools and hospitals, as well as for appointment reminders and thank you calls.
- For more information, see Part III and Part IV of the Unsolicited Telecommunications Rules.
5. Complaints
- Complaints about telemarketers can be made through the National DNCL website (www.LNNTE-DNCL.gc.ca) or by calling the toll-free numbers 1-866-580-DNCL (1-866-580-3625) or 1-888-DNCL-TTY (1-888-362-5889).
- Types of complaints can include receiving a call even though you have registered on the National DNCL, receiving a call outside of permitted calling hours, a telemarketer who does not put your name and number on their do not call list, or any other violation of the rules.
- When making a complaint, remember that you must provide information such as the date of the call and the name or telephone number of the telemarketer.
- The CRTC will investigate complaints and can penalize telemarketers found to be in violation of any of the CRTC’s Unsolicited Telecommunications Rules.
- As of September 30, 2008, the CRTC can levy penalties of up to $1,500 for an individual and up to $15,000 for a corporation, for each violation.
Source : http://www.crtc.gc.ca/eng/INFO_SHT/t1031.htm