login | register
Fri 09 of May, 2008 [16:44 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.
 
Google Ads
Shoutbox
  • Nick Barnes, Fri 09 of May, 2008 [11:36 UTC]: Christopher - yesterday I tried an Asterisk install on a CentOS 5.1 box with stock GUI and it all worked fine. Sorry I can't help.
  • aero, Fri 09 of May, 2008 [08:20 UTC]: can someone help me out on this, i tried to play some sound files on my asterisk box and this is the error message i got. WARNING[4429]: format_wav.c:169 check_header: Unexpected freqency 22050 May 8 11:17:39 WARNING[4433]: codec_gsm.c:194 gsmtolin_fra
  • Christopher Faust, Thu 08 of May, 2008 [14:15 UTC]: I beleive that I may have to change something in the xserver configuration. Please advise
  • Christopher Faust, Thu 08 of May, 2008 [14:14 UTC]: Everything was perfect. In the bios I have increased the memory allocated Still receive input not supported on my display.
  • Christopher Faust, Thu 08 of May, 2008 [14:13 UTC]: This would not be my main box. I am doing some testing to see if I can install zaptel and asterisk 1.4 on a full centos 5.1 box with development software Its bizzare, because before I went through the asterisk and zaptel installation everything was perfe
  • Nick Barnes, Thu 08 of May, 2008 [13:44 UTC]: Christopher - I can't see any way in which an Asterisk installation would muck your GUI, but remember that it is advised not to use a GUI on an Asterisk box anyway.
  • Christopher Faust, Wed 07 of May, 2008 [15:28 UTC]: When I try to startx I ge input not supported. Though before installing asterisk I had no video issue to start the GUI
  • Christopher Faust, Wed 07 of May, 2008 [15:26 UTC]: Hi Nick, I got centos 5.1 and asterisk up But now I cannot start startx I have set the depth from 24 to 16 for the video i810 driver for the i845 on my netvista machine but I cannot start GNOME. Please advise
  • Nick Barnes, Wed 07 of May, 2008 [10:01 UTC]: Howard - You'll need to provide a lot more information if you really want help.
  • Nick Barnes, Wed 07 of May, 2008 [10:00 UTC]: Christopher - Search the Wiki and you'll find a page I wrote detailing exactly what you have to do for Asterisk 1.4 + CentOS 5.1.
Server Stats
  • Execution time: 0.25s
  • Memory usage: 2.28MB
  • Database queries: 29
  • GZIP: Disabled
  • Server load: 0.73

Asterisk auto-dial out

Automated dial out

The Asterisk dial plan extensions.conf responds to someone calling an extension on a channel. If you want to initiate a call from an external application, there are several ways to do this.

There are basically four ways to initiate outgoing calls in Asterisk
  • Use .call files. A call file is a text file that when placed in the correct directory makes Asterisk make an outgoing call.
  • Use the manager API to activate a call. See Asterisk manager dialout
  • Use the Asterisk CLI originate command
  • FollowMe command of Asterisk 1.4: Since this has the abitility to fork (create multiple calls) it could be 'misused' to initiate outgoing calls.

See also additional Digium documents.

Call files

  • Move a call file into /var/spool/asterisk/outgoing
  • Asterisk will notice and immediately call the indicated channel and connect it to the specified extension at the priority specified in the call file.
  • If the modification date on the call file is in the future, Asterisk will wait until the modification date arrives before executing the call file.
  • Example: See "sample.call"
  • if autoload=no in modules.conf be sure to load pbx_spool.so, otherwise call files will not work

Syntax of call files

  • 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

At least one of app or extension must be specified, along with channel and destination

The 'failed' extension

If the call is not answered, and the standard extension failed with priority 1 exists in the same context, control will jump there (feature introduced in either Asterisk 1.2 or 1.4. NOTE: This works in asterisk 1.2.14)
    • Note 1: This only works if you made the call with context, extension, and priority defined, and didn't use the application, data form.
    • Note 2: This is a good place to update the CDR UserField with a value of the phone number that was being dialed using the SetCDRUserfield() application. Asterisk (as of 1.2.10) does not make the dialed channel (eg. IAX2/15551234567) available anywhere, so you have to pass it to yourself using Set: field of the .call file. (Along with anything else you want pass to the channel in this same variable).

Example

In .call file:
Set: PassedInfo= 15551234567-moreinfo-evenmoreinfo 

extensions.conf
exten => failed,1,Set(NumberDialed=${CUT(PassedInfo,,1)})
exten => failed,n,SetCDRUserField(${NumberDialed})



Scope of variables

  • Make sure you know what prefixing a variable with _ or __ does!
  • Especially Asterisk 1.0 and 1.2 behave differently for what concerns a) passing on variables to channels and b) global variables
  • Consider using DBGet and DBPut if you experience trouble passing variables

Creating and moving call files

Because Asterisk can grab these files at any time (e.g. when the file is only 1/2 written), do not create the file directly in the /var/spool/asterisk/outgoing directory. Do something like this:
  • create the call file in a different directory - e.g. /var/spool/asterisk/temp1234
  • chown asterisk:asterisk /var/spool/asterisk/temp1234 (if temp1234 was created by root and Asterisk is running as username asterisk)
  • mv /var/spool/asterisk/temp1234 /var/spool/asterisk/outgoing
This works because the Unix move operation (mv command) merely moves the "inode" — the pointer to the file — making the entire file appear all at once and eliminates the possibility that Asterisk could read and act upon a partially written file. (Note that this is only true if the source and destination are on the same file system; otherwise, it does the equivalent of a "cp"; see below.)
Note: Using the copy command (cp) is not a safe method for adding a file to the outbound directory since other programs can read the new file in the midst of the copy operation when the file is only partially written.


Examples

Example 1

Filename: 1.call

 
 Channel: Zap/1/1XXXXXXXXXXXX
 MaxRetries: 2
 RetryTime: 60
 WaitTime: 30
 Context: callme
 Extension: 800 
 Priority: 2



This will hook up to priority 2 of extension 800 in context callme in extensions.conf.

Example 2


To create a call to 14109850123 on an analog channel in group 2 and then connect it to the hypothetical extension 84 (which would map to 84,1,Dial(SIP/84) ) inside your network, here's the file you'd create in /var/spool/asterisk/outgoing:

 #
 # Create the call on group 2 dial lines and set up
 #  some re-try timers
 #
 Channel: Zap/g2/14109850123
 MaxRetries: 2
 RetryTime: 60
 WaitTime: 30
 #
 # Assuming that your local extensions are kept in the
 #  context called [extensions]
 #
 Context: extensions
 Extension: 84
 Priority: 1



The above examples are good if you want to automatically play some recorded message, or something automatic that must start when the other party picks up the phone. In fact if you use the above for a conversation, you will have the outgoing phone ring, and when the other person picks up his phone, only then your extension starts to ring, so you miss the initial "hello" and maybe some more words!
If you have outgoing calls in your dialplan defined in the [outgoing] context, to call 14109850123 do this:

Example 3


To create a call to 14109850123 on a SIP phones called bt101, here's the file you'd create in /var/spool/asterisk/outgoing (whatever name is good, of course must be accessible and deletable by asterisk GNU/Linux user):

 Channel: SIP/bt101
 MaxRetries: 1
 RetryTime: 60
 WaitTime: 30
 #
 # Assuming that your outgoing call logic is kept in the
 #  context called [outgoing]
 #
 Context: outgoing
 Extension: 14109850123
 Priority: 1



Example 4


Auto dial a number and play a prerecorded message, allow replay, and message acknowledgement
See: Auto-dial and Deliver Message


Example 5


To create a call to an internal or external extension connected to an AGI

 Channel: Local/1000@from-internal
 MaxRetries: 0
 RetryTime: 15
 WaitTime: 15
 Application: AGI
 Data: myagi.agi


On a trixbox/freepbx system this will dial internal extension 1000 (or you can put even an outside # here and it will follow outbound rules) and connect it to an AGI program. Note that unlike in extensions.conf where you can specify AGI(file.agi), here it must be separated. I use one agi to detect an incoming call to a special extension#, record the caller id, and then create the .call file to call back that number and connect it to a second agi.

How to schedule a Call in the Future

Files with a modified date in the future are ignored until that time arrives. Create the file in /var/spool/asterisk/tmp, modify the mtime using "touch", and then move it...


 $ date
 Mon Mar 19 13:52:30 EDT 2007
 $ touch -d 20080101 /var/spool/asterisk/tmp/blah
 $ mv /var/spool/asterisk/tmp/blah .
 $ ls -l blah
 -rw-r--r--    1 andrew   users           0 Jan  1 00:00 blah




Bash example: to schedule a call in 100 s :

 # gives you the current time in seconds since dawn of UNIX
 NOW=`date +%s`
 # add 100 seconds
 let NOW=$NOW+100
 # create a timestamp used by 'touch -t' (no space between %M. %S, but the Wiki wants a space at this place)
 TOUCH_TMSP=`date -d "1970-01-01 $NOW sec GMT" +%Y%m%d%H%M. %S`
 # and do the touch
 touch -t $TOUCH_TMSP blah


Tip on managing the number of simultaneous outbound calls

You can limit the number of simultaneous outgoing calls by managing the number of files in the outbound directory (/var/spool/asterisk/outgoing). For example, to limit Asterisk to only doing 10 simultaneous outdials just limit the number of files in the outbound directory to 10 at any one time. As the number decreases, you can move additional files into the directory to maintain the number of outgoing calls at the desired level.

Note: There are various user reports of Asterisk choking (=not processing some of the .call files) when too many files are moved simultaneously into the outgoing directory. Therefore it may be advisable to move them step-by-step with a slight delay.
However, even then it is possible that Asterisk once in a while 'forgets' to process a call file (seen e.g. in 1.0.9). Possible soltuions:
  • 1. Find the cause and fix it in the source code,
  • 2. Use the Manager API which hopefully doesn't exhibit this problem,
  • 3. Design your application to cope with this effect, for example counter check the existence of CDR data against your .call file details (execution time, destination, accountcode etc).

More examples


Callfiles and Call Detail Records

  • Avoid missing CDR records: Use either a) Context/Extension/Priority in the call file instead of Application/Data, or b) call a Local channel instead of directly calling the desired channel. Else Asterisk will bypass the process that tracks the call and no CDR record will be generated. When using Context/Extension/Priority, you are really using a Goto type function which just puts the call into the correct part of the dialplan and to it is the same as if the caller had dialed the call manually and so the call is logged.
  • The phone number you are dialling will not be stored in the CDR by * - if you need this information for CDR processing you can set the CallerID in the call file to this number and it will be stored. However, this will present the person you are calling their own phone number, which doesn't make much sense. A better solution might be to put the number you are dialing in the Set: channel variable in the .call file and later put it into the UserField of the CDR. See example above in the first section.

Tips and hints

  • Create the call file elsewhere, and move it (better not use copy, see above) into the directory after you're done creating it. Asterisk is very aggressive in grabbing these files, and if you're still creating it when it grabs the file, you'll get errors, so best to create first and then copy in to the outgoing directory all at once.
  • The call file must be owned by the user asterisk runs as, so asterisk can utime() it, or you will get permission errors.
  • If you are using POTS (Plain Old Telephone System) lines attached to a channel bank with FXO cards, it's likely that you will run into problems sensing when your callee picks up their phone - especially to cell phones. Once Asterisk hands off a call to an FXO line (ie, it starts to ring), the system counts the call as 'answered', and continues its merry way. This means that your voice prompts get played to a ring tone, and your users are presented with a silent call.
Some things to try:
    • In zapata.conf, try adding callprogress=yes above your channel => n definition for the FXO lines. (remember that settings set above the channel flow down, and that you need to clear this setting with a callprogress=no for any channels you might not want this to affect!)
      • This is experimental, only sometimes works, and only for North American tones.
      • On my system, this setting failed miserably, to the point that I could no longer make outgoing calls, and calls were dropped.
    • Another option (At least in example 3), is to repeat your message. Note the ResponseTimeout(2), to set the pause between repeats to 2 seconds, and the GoTo(s|1), to repeat the prompts.
    • Yet another option is to use an application like "WaitForSilence" that will wait for a certain amount of silence before beginning to play the message. See bugs.digium.com #2467 for this app, which will probably soon appear in CVS.
  • Try app_machinedetect.c application for detection of answering machines. This works best with PRI, VoIP, or a POTS with callprogress enabled.

A Few Ideas

What can you do with this interface?
  • Set up a cron job to dial out at specific times
  • You could start at an extension that checks if a user is logged in (chanIsAvailable) and if so, dials and reminds the user to log out, go home and go to bed :-)
  • Have other applications create call files for alerts or alarms
  • Dial a call group with agents
  • Create a own callback from an extension, by using DISA. Caller calls the asterisk, asterisk hangs up and call him back, gives him a "free line" to call out!

See also



Go back to Asterisk

Created by oej, Last modification by Russ on Mon 04 of Feb, 2008 [14:09 UTC]

Comments Filter

.call files

by Geoff on Thursday 21 of February, 2008 [10:30:50 UTC]
Hi,

I have followed the instructions here and tried to create .call files for both internal extension and external calls. The files have the correct permissions and disappear when copied to the outgoing directory but nothing then happens. I have looked through the logs and watched Asterisk CLI in the verbose mode and nothing appears. Is there somewhere else I can look for troubleshooting this?

Thanks very much for any help. I am a newbie at this so please excuse me if this has been answered before.

Can i make a call using CallerPres?

by Ernazar on Tuesday 19 of February, 2008 [14:08:30 UTC]
I have Asterisk 1.4.18 and i would like to make a auto-dial out through Zap channel using callingpres=prohib_not screened.
I tried to set up CallingPres using application SetCallerPres, but it doesn't work because it must be set before making a call.
Is there any way to make it except changing source code of chan_zap.c?

using call files to make SIP calls on Teliax

by Baji Panchumarti on Tuesday 06 of November, 2007 [17:07:13 UTC]
The steps should work the same no matter who your ITSP is, the important thing is that you DONT NEED a DIAL step in your extensions.conf.

But you DO NEED to format your call file as follows (the # to be called needs to be in the channel statement) :

Channel: SIP/3012345678@teliax
CallerID: Spiderman <3015551212>
MaxRetries: 1
RetryTime: 600
WaitTime: 30
Context: outgoing
Extension: spidey
Priority: 1

Then in extensions.conf you need to have an "outgoing" context with extension "spidey" as follows :

outgoing
exten => spidey,1,Answer()
exten => spidey,n,Wait(0.5)
exten => spidey,n,Playback(hello-from-spiderman)
exten => spidey,n,Hangup()

so you are calling (301) 234-5678 as Spiderman from (301) 555-1212.

Is it possible to run >1 applications from one call file?

by Vadim Mikhnevych on Friday 26 of October, 2007 [13:03:50 UTC]
Is it possible to run multiple applications from one call file using Application field, or this can be done only using Extension with multiple commands?
If i put two Application fields in one file, it seems to use the last one only, ie this one calls only playback , and if i swap them - only UserEvent :
<...>
Application: UserEvent
Data: <some data>
Application: Playback
Data: tt-monkeys

Is it possible to do SIPAddHeader in .call file or other solution

by Ming-Hsun,Tsai on Monday 10 of September, 2007 [05:56:33 UTC]
I had tried to add sip header by put

fputs($cf,"Set: SIP_HEADER(X-myACCT)=foo@bar.cc "\n");

before placing the .call to outgoing folder. but failed due to the SIP_HEADER is read-only.
Is there any possible solution to accomplish this request ? Thanks in advance :)

Removal of .call file

by Rob Carsey on Monday 21 of May, 2007 [18:45:38 UTC]
Suppose you place a .call file in the outgoing spool directory as you normally would — and set the maximum number of retries to 5. If the outgoing call is never answered (all 6 times, 1 try, and 5 retries), then the failed extension (priority #1) is jumped to after each of the "failed" calls. This is useful for CDR and such.

However, I find myself in a situation where all I really care about is whether the the .call file was removed from the spool directory because a call was successful.. or because it exceeded max retries.

Is there a way to do this? I'd have thought that there would be a special extension for the case of the final attempt of a call.

what Channel

by False South on Wednesday 09 of May, 2007 [21:51:40 UTC]
Hi - This page gives the following examples of channels that can be used in your call file:

Channel: Zap/1/1XXXXXXXXXXXX

Channel: Zap/g2/14109850123

Channel: SIP/bt101

Channel: Local/1000@from-internal

How do I know what channel is the best to use in a given suituation?

Re: ZAP auto-dial not working!

by Makuro on Wednesday 27 of September, 2006 [08:49:13 UTC]
Try instead of ZAP/1/1408xxxxxxx this: ZAP/g1/1408xxxxxxx

the g within means, that asterisk will take the first free line on your card.

else you can try to make an own extension, for you.

means in extensions.conf:

automation
exten => 1,1,Answer
exten => 1,2,Dial(SIP/202,30)
exten => 1,2,Hangup

and change the settings in the callfile to Extension: 1 and Priority: 1


HTH, thats how i got it work with autodial and IAX Softphones over similar workstations.

ZAP auto-dial not working!

by batmon on Friday 01 of September, 2006 [22:31:12 UTC]
It works great if I auto-dial to my own SIP extension. If I want to auto-dial to an outside nuber through my ZAP trunk, the outside # never gets the call. Any idea?

Working One:

Channel: SIP/202
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: outboundmsg1
Extension: s
Priority: 2


not working one:

Channel: Zap/1/1408xxxxxxx
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: outboundmsg1
Extension: s
Priority: 2


I am using a X101P card. I can dail-in and call-out fine through this ZAP trunk. But the auto-dial just won't work!

Please help! Thank you.

AGI Control of Call...

by harlequin516 on Sunday 26 of March, 2006 [21:35:01 UTC]
When you originate a call asterisk essentially callouts to the Specified channel and the when answers connects the the context,extension,priority. What if I want my dial plan to make the origination call and the destination call. What would I specify for my dialplan/callout file?

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2008 VOIP-Info.org LLC

Powered by bitweaver