Couldn't find a specific answer for this. I'm a newbie to asterisk and AMI. I need to auto generate calls using asterisk and pass parameters to an AGI program. Using a call file seems to generate the call first which is not wanted. So, how do I use asterisk AMI API (PHP) to execute a dialplan with AGI in it, by passing all parameters to it? So, the AGI will take over and make the call.
I think in your case, using call files would actually be simpler. Here's why:
The AMI requires you to write networked code, which (if you're a beginner) will be a lot more tricky the building simple text files (Call Files).
Call Files allow you to pass variables to Asterisk that you can use in your dialplan code.
Call Files are extremely simple.
Below is a full example of a simple way to do it using call files. I've tried my best to explain it in the associated comments.
Firstly, let's assume you have some dialplan code that uses variables, and calls an AGI script (which is what I assume you're doing based on your question). That means you'll have code in your extensions.conf file that looks something like:
[test_stuff]
exten => s,1,NoOp(starting test!)
exten => s,n,NoOp(my variable's value is: ${somevar})
exten => s,n,NoOp(my other variable's value is: ${some_other_var})
exten => s,n,AGI(/path/to/my/script.sh,${somevar})
exten => s,n,NoOp(i just ran an AGI script and passed it a command line argument!)
exten => s,n,Hangup()
Below is a call file that will:
Need to be created in some temporary directory (maybe /tmp/).
Once it has been saved, you can run it by moving it to /var/spool/asterisk/outgoing/ (eg: mv /tmp/blah.call /var/spool/asterisk/outgoing/).
The call file will the immediately dial outbound to the phone number 818-222-3333.
Once the person at 818-222-3333 picks up the call, Asterisk will immediately start executing your [test_stuff] dialplan code, and will have the variables set in your call file available to it.
Call file:
Channel: SIP/trunkname/18182223333
Context: test_stuff
Extension: s
Priority: 1
Set: somevar=hithere
Set: some_other_var=woot
Hope that helps!
Your problem can be solved with the help of local channel for example
In call file use Local/1812222222#test_stuff as channels while using following dialplan
[test_stuff]
exten => _X.,1,NoOp(starting test!)
exten => _X.,n,Set(phone=${EXTEN})
exten => _X.,n,AGI(/path/to/my/billing,${phone},${other_variables_account_etc..})
exten => _X.,n,Dial(SIP/trunkName/${phone})
You can use this method with both interfaces AMI or .call file
Related
As a beginner that just installed his first asterix server I came across a small issue. i want to check if a number that i dial is busy or not before actually dialing it.
So for example I would call 0904 => number busy => redirect to 0905
However I don't want it to dial 0904 first if its busy but just instantly redirect it to 0905 instead.
I have a very basic setup with just 3 users. 2 of them are in a queue "support" one of them is in the queue "admin"
I have seen and read a little about checking if a channel is available but i didn't fully understand that and I'm not sure if it could be done easier.
Here is my simple dialplan, if i call *12 my simple python script will just execute the Dial command to the 0904.
exten => *12,1,Answer()
same => n,set(PHONE_EXTEN=0904)
same => n,AGI(test-agi.py,${PHONE_EXTEN})
same => n,Hangup()
There is no way know if external number is busy.
If number is your extension, you can count calls using GROUP/GROUP_COUNT or you can check extensions states and hints, like described in docs
https://wiki.asterisk.org/wiki/display/AST/Extension+State+and+Hints
https://wiki.asterisk.org/wiki/display/AST/Device+State
Set up Asterisk 13.1 on Ubuntu 16.04,Calls are Working fine as well as conference calls.However I have two Question regarding the recording of calls in asterisk.
This is the extensions.conf.
[default]
exten => 1000,1,MixMonitor(${CALLERID(num)}-${STRFTIME(|EST5EDT|%m%d%Y-%H%M%S)}.gsm)
same => n,Dial(SIP/1000)
exten => 1001,1,MixMonitor(${CALLERID(num)}-${STRFTIME(|EST5EDT|%m%d%Y-%H%M%S)}.gsm)
same => n,Dial(SIP/1001)
exten => 100,1,Answer()
exten => 100,n,Authenticate(234)
same => n,MixMonitor(${CALLERID(num)}-${STRFTIME(|EST5EDT|%m%d%Y-%H%M%S)}.gsm)
same => n,ConfBridge(1234)
And this is confbridge.conf
conf => 1234
[1234]
record_conference = yes
1)Is it necessary to define MixMonitor for every call(As I have done above for user 1000 and 1001) ,or is there a possibility where you can define it once and all calls in your asterisk server get recorded.
2)When the Conference call is recorded ,suppose if there are two users in the conf room,there are two audio files generated instead of one,What changes do I make so theres is only one recorded audio file of the full conference?
In asterisk it is nessesary do any action you want DO.
In your case you can use mixmonitor command in every dialplan, use pattern to do that command for large list, use external macro or gosub function and call it for calls you want be recorded.
For conference you can start enother call with mixmon(third call) using Originate or you can use internal recording.
For ANY record you can have Monitor(two files for each side of call) or mixmonitor(same, but 1st party in left channel, 2nd party in right channel, so file is single).
So if you have 2 files, you just have non-mixed variant. Consult conference room options for mixed version.
I am using call files such as these:
Channel: SIP/TRUNK/1-111522282783163<br/>
CallerID: 522299308962<br/>
MaxRetries: 1<br/>
Data: GqFR7rubPw_10<br/>
Context: calls<br/>
Extension: s<br/>
Priority: 1 <br/>
Setvar: AUDIOFILE=GqFR7rubPw_10<br/>
Setvar: ID=BkzKlksau1<br/>
Setvar: DEST=522282783163<br/>
Archive: yes<br/>
As I already know, when the call is answered the dialplan (in the context) is executed but not with the calls that are "NO ANSWER, CONGESTION, BUSY, FAILED". What I want to do is execute a dialplan (in the same context or default context) when a Call is in the status that are not ANSWERED because I add an ID as variable in the call files which I use to identify the call.
I found this link Asterisk - executing agi script if call is not answerd? But I don't understand to be honest with you. If someone has an example of this I will appreciate it.
Dial Plan:
[calls]
exten => s,1,wait(2)
exten => s,n,Set(CDR(outbound_cnum)=${DEST})
exten => s,n,Set(CDR(userfield)=${ID})
exten => s,n,Playback(${AUDIOFILE})
First of all it is not only issue you will get in attempt of writing your own dialling core. It is HIGHLY recommended use already written core/some opensource project.
This exact issue can be fixed by using Local/ channel and call via dialplan. That way you will get feedback on dialplan and can check DIALSTATUS variable after end of call.
https://wiki.asterisk.org/wiki/display/AST/Local+Channel
I have
[from-pstn]
exten => s,1,Playback(demo-thanks)
as the first line in the context of a dialplan. It does not work.
However, when it is replaced by this:
[from-pstn]
exten => _X.,1,Playback(demo-thanks)
It works. Is the "s" extension not the start extension?
This is the dialplan on a PRI line. When the caller calls in, the first line in the [from-pstn] context is triggered. The "front-pstn" context is referenced in dahdi.conf. That is not the source of the problem as it would not have worked with the _X. extension.
I am just starting to write Asterisk dialplans.
s-extensions is empty extension.
I.e it used when no number
Very likly you have number, so it go as number and match regexp X. in your dialplan.
For more info connect to asterisk console, enable verbose output and see what happens while calling
asterisk -r
core set verbose 5
I have an asterisk server. I use the server to connect an incoming call to another extension based on a few key presses. There is a certain time lag (after the key/extension press and before the call connects). How can I play a small music file (of my choice) in this period? There are some constraints that come to my mind:
The music should play only as long as the call does not connect. So, the method used should be a non-locking one.
Any help on this is most welcome.
Thanks,
Sriram
Use the m flag to the Dial application, to play music on hold while the call is connecting.
exten => 9000,1,Noop
exten => 9000,n,Answer
exten => 9000,n,Dial(SIP/device,0,m)
I think Background is your friend (http://www.voip-info.org/wiki/view/Asterisk+cmd+BackGround)