Using Asterisk 11, with an inbound route configured to call Queue app, every time the caller hangs up the HANGUPCAUSE variable is 0, it works and returns the NORMAL_CLEARING code only when the assigned queue member hangs up or if not using queues. Example code:
[from-trunk]
exten => s,1,Answer()
same => n,Queue(queue-1,rkt,,,30)
exten => h,1,Verbose(Hangup cause is ${HANGUPCAUSE})
How to obtain a valid HANGUPCAUSE from calls answered with queues?
Asterisk HANGUP_CAUSE will show you only value of last Dial command and only for SOME channel types.
Queue generate 100500 of NEW calls and bridge it together to make functionality you want.
You can check cause in queue's branches(in each one can be DIFFERENT), using agents in Local/ channels.
You can use Queue app variables:
This application sets the following channel variables upon completion:
${QUEUESTATUS}: The status of the call as a text string.
TIMEOUT
FULL
JOINEMPTY
LEAVEEMPTY
JOINUNAVAIL
LEAVEUNAVAIL
CONTINUE
${ABANDONED}: If the call was not answered by an agent this variable will be
TRUE.
You also can use queue_log or CDRs.
Related
I have an asterisk which is originating various calls.
Which is the most elegant way to send and email (or more generally trigger an event) when it fails to call a certain amount of time in a row?
For instance: When more than 20 calls fail because of insufficient credit, send an email.
My solution: Schedule using crontab a scripts that grep log files (cdr-csv) and do the requested operation.
Most elegant/lower cpu usage is use AMI event listener and trigger UserEvent with request of email.
To trigger UserEvent you can use h extension
exten => _X.,1,Dial(SIP/trunk/${EXTEN},,o)
exten => h,1,ExecIF($[ ${DIALSTATUS} != "ANSWERED" ]?UserEvent(TrunkFailed,Status: ${DIALSTATUS})
I'm using Asterisk 11. I have a problem to get channel name when I attempt to call-out.
Usually, I can get the channel name when the called party picks up his/her phone. But now, I would like to get the channel name right after I dial out. I can see it on the screen like this:
Called SIP/7146991234#64.195.139.88
- SIP/64.195.139.88-00000001 is ringing
-- SIP/64.195.139.88-00000001 is making progress passing it to SIP/8001-00000000
I know that the channel name is : "SIP/64.195.139.88-00000001",
but I don't know how to get it from coding or any other ways.
Please help me.
Thank you very much!
You can get the name of the outbound channel in Asterisk 11 using a Pre-Dial Handler on the called channel.
[default]
exten => pre_dial_handler,1,NoOp()
same => n,Verbose(1, Channel is ${CHANNEL})
same => n,Return()
exten => dial_example,1,NoOp()
same => n,Dial(SIP/alice,,b(default^pre_dial_handler^1)
This will execute the subroutine pre_dial_handler on channel SIP/alice-XXXXXXXX, as opposed to whatever channel is actually performing the dial operation. The subroutine is executed on the outbound channel immediately after creation but before any operation is taken on it, such as making a call attempt.
You can't get channel name of outbound channel in dialplan
Reason: it not created yet at that moment.
But you can get it by external application by checking variables BRDIGEDPEERNAME or listnen event.
Also you can get both channels in cmd_dial internal macro(M param)
I just installed Asterisk 11 and a2billing 2.01. I followed instructions for the a2billing installation and everything was OK. It works.
But... There are no call traces being recorded into the a2billing database!!!
As I understand it, it uses the "cc_call" table for call recording - but this table is empty!
I need all calls recorded, not only answered. I'm making calls via AGI using their PHP scripts. The following is my dial plan:
;For standard inbound call
[a2billing]
exten => _X.,1,NoOp(A2Billing Start)
exten => _X.,n,Agi(/usr/share/a2billing/AGI/a2billing.php,1)
exten => h,1,Hangup
This starts the IVR which tells me my account balance (how much money I have left), and then asks me to choose a number to dial.
I have a trunk for the call, created as has been recommended. After the call my balance is decreased; i.e., the call has been charged. But I cannot see any call records inserted into the database.
My questions are: How exactly does a2billing generate CDR's? What do I need to do to have the calls recorded?
As mentioned by arheops, A2billing store CDRs in it's own Mysql Database, within a table called cc_call, the table is very similar to the Asterisk CDR table but contains extra fields to store the buy/sell rates, cost of calls and relation to the rate/callplan tables.
When you send a call to the AGI, A2Billing will try first to authenticate the users, if it succeed then the outbound call will be saved.
A2Billing create cdrs via by agi script. You can got it in cc_call table.
For record calls you have change agi-confX and set key for recording(in config section of web)
Scenario:
Asterisk receives incoming call to a DID number
Asterisk forwards incoming call to a mobile number using PSTN termination.
Call is answered on a mobile
Question:
Is there a possibility to transfer call to a different extension during the call ?
yes,but require guru level.
it can be done by writing special application or using conference or using AMI.
probably easy way is conference
Yes. This is very straight forward.
Presuming your DID is 1-234-567-8900 and your moble is 1-987-654-3210:
exten => _12345678900,1,NoOp(Call for DID to Mobile)
same => n, Dial(DAHDI/g1/19876543210,30,t)
same => n, HangUp()
The dial option "t" allows "...the called user to transfer the call by hitting the blind xfer keys (features.conf)"
Further reading: http://www.voip-info.org/wiki/view/Asterisk+cmd+Dial
I want to pickup call in Asterisk using AMI. I can originate call, but totally don't know, how to answer the phone...
Script for calling:
#login
sock = socket.socket(af, socktype, proto)
sock.connect(sockaddr)
sock.send('Action: login\r\n')
sock.send('Events: off\r\n')
sock.send('Username: '+str(ast_server.login)+'\r\n')
sock.send('Secret: '+str(ast_server.password)+'\r\n\r\n')
#originate call
sock.send('Action: originate\r\n')
sock.send('Channel: ' + str(user.asterisk_chan_type) + '/' + str(user.internal_number)+'\r\n')
sock.send('Timeout: '+str(ast_server.wait_time*1000)+'\r\n')
sock.send('CallerId: '+str(user.callerid)+'\r\n')
sock.send('Exten: '+str(ast_number)+'\r\n')
sock.send('Context: '+str(ast_server.context)+'\r\n')
if ast_server.alert_info and user.asterisk_chan_type == 'SIP':
sock.send('Variable: SIPAddHeader=Alert-Info: '+str(ast_server.alert_info)+'\r\n')
sock.send('Priority: '+str(ast_server.extension_priority)+'\r\n\r\n')
#logout
sock.send('Action: Logoff\r\n\r\n')
time.sleep(1)
sock.close()
I need something similar, but for answering calls.
Can't find any useful command in *CLI> manager show command
Halp me, plox
You can't answer a call directly via AMI. This is because a new call will "arrive" at the given context/priority/extension configured in the dialplan (or it will be rejected if cant find one that applies). So whatever happens with that call will start at the given context/priority/extension in the dialplan.
If you want to handle calls via AMI, try using asynchronous AGI, like this:
exten => _X.,1,AGI(agi:async)
This will handle all calls to any extension that has at least 1 digit, by issuing an event (AsyncAGI) that you can handle with your AMI client.
Then, from your AMI client, you can send AGIAction's, like:
Action: AGI
Channel: SIP/adevice
Command: ANSWER
CommandID: MyCommandID
This will effectively allow you to run AGI commands (and handle a call like you would normally do in any AGI script) from your AMI client.
Hope it helps!