How to get actual number of channel in asterisk 13? - asterisk

In asterisk 1.4 number of channel was specified in chan->name.
e.g. number 62:
asterisk 1.4 ZAPTEL: Zap/62-1
How to get actual number of channel in asterisk 13 in c-language?
e.g. in chan->name this number of span only.
asterisk 13 DAHDI: DAHDI/I2/102-1
Here is what R.Mudget say about extentons.conf:
You can use the AMI action DAHDIShowChannels to get the current channel mapping.
There is an AMI event that you can look for:
Event: DAHDIChannel Channel: name Uniqueid: id DAHDISpan: 5
DAHDIChannel: 23
It is generated whenever a call is assigned to a B channel or a call moves to a different B channel.
There is also the CHANNEL() dialplan function:
CHANNEL(dahdi_channel)
CHANNEL(dahdi_span)
CHANNEL(dahdi_type)
The DAHDIChannel event and CHANNEL() function are mentioned in the UPGRADE.txt file.
Richard
But how do I get an actual number of channel in c-language API?

Simplest way answer this question is read source code(writed in c/c++) of chan_dahdi and see how dahdi_channel variable is set in YOUR dahdi/asterisk combination.
You also can use ami from c/c++, but that is not optimal.
In general you should not see number of channel in channel-name unless you setuped one-channel-one-span.

Related

How to auto-transfer inbound call to an outside number in Asterisk?

How to automatically transfer inbound call to an outside number in Asterisk server?
Example:
When a customer calls to a tollfree number it's connected to my call center server.
Here we have 3 options: 1 for English, 2 for Telugu and 3 for Hindi.
If the customer selects option 1, they should be redirected to a dealer number.
If the customer selects option 2 it redirect to my private line. This option is working fine because this number is an internal number.
I'd like to know how to auto-transfer the inbound call to an outside number in Asterisk if customer selects option 2?
If you have a SIP gateway, you first need to register it in sip.conf
register => user:pass#gatewayip/number_from_gateway (so you can make outbound calls)
then for option 3 for example you can assign an internal number 103, and you can send the call to 103:
exten => 103,1,Dial(Local/EXTERNALNUMBERHERE,45,tr)
There are manuals online, and this can easily be found, with more examples. So please do your digging before asking here ;)

How to save Remote Party ID to CDR in Asterisk?

I'm new to Asterisk so any help will be greatly appreciated.
I'm trying to save remote party ID (CONNECTEDLINE) in CDR logs table in transferred calls. In blind transfers there's no problem because I'm getting Remote Party ID as Caller ID in src field.
In attended transfers I'm loosing the original caller ID.
This is how transfer goes:
A calls B (A talking with B)
B holds A, and calls C (B talking with C)
B transfers A to C (A talking with C)
Now, in CDRs table I'm getting two records. One for the first call (A<->B), and another for the two second calls (B<->C and A<->C). The point is in second CDR I have lost any reference to A.
I want to save Remote Party ID (A) in second CDR.
I've already added a custom field to CDR table (connectedID).
I'm reading about editing some configuration files, adding this kind of sentences:
"exten => s,1,set(CDR(connectedID)=${CONNECTEDLINE})"
However, I'm quite lost. I don't know which file I need to edit, even in what part of file I should put these lines of code.
Could somebody point me in the right direction?
You can use Func_SHARED,save cid in shared variables and do lookup by bridged channel name
However that all require debugging and your own effort.
http://www.voip-info.org/wiki/view/Asterisk+func+shared
Other option is collect events and remmember all transfers
Reading call events via AMI (thanks to #arheops) I manage how to save Remote Party ID in CDR.
In hangup event we can see Remote Party ID in ConnectedLineNum field.
For a transferred call like this one:
401 calls 208
208 calls 308 (401 on hold)
208 transfers original call to 308 (401 talking with 308)
this is a hangup event sample for the final segment of the call.
Event Hangup
Privilege: call,all
Channel: SIP/308-00000665
Uniqueid: 1421757614.1658
CallerIDNum: 208
CallerIDName: Juan Ruiz
ConnectedLineNum: 401
ConnectedLineName: Test1
Cause: 16
Cause-txt: Normal Clearing
Original caller is stored in ConnectedLineNum variable.
So I add this line to the hangup section:
exten => s,1,Set(CDR(connectedid)=${CONNECTEDLINE(number)})
I'm using Elastix 2.4.0, so I've added this line at the beggining of the [macro-hangupcall] macro in extensions_override_elastix.conf file.
In other Asterisk based distros it should be in another file.

Asterisk - Reseting CDR to show correct billsec of a new call when channel is answered beforehand

What I want to do:
Answer an incoming call and Dial another number. When call is finished I need to have the correct conversation time of the call (which is supposed to be stored in ${CDR(billsec)}).
What I am getting:
Since the channel is answered, the C option in Dial application is only resetting the answer variable of CDR to current time therefore the resulting billsec is equal to duration variable of CDR and is equal to channel seize time not call conversation time.
My dial plan:
exten => 333333,1,NoOp(Here I answer the channel and make another call)
same => n,Answer
same => n,Dial(DAHDI/g0/123456789,,gC)
same => n,NoOP(Billsec: ${CDR(billsec)}) // Here billsec is equal to CDR(duration)
Note: If I simply remove Answer CMD from dialplan then billsec variable is showing the correct call time and this makes sense because channel was not answered and CDR(answer) will be assigned as soon as called party answers the channel. But the problem is that in my complete dialplan I have to answer the channel before making the call because I need to interact with user beforehand and it needs the channel to be answered.
BTW, I am using Asterisk 13.0.0-beta1. Could any of you guys let me know how can I achieve what I want to do please?
If basic CDR functionality is not enough for billing, check out CEL (Channel Event Logging). Supports all the DB backends, and has all the event's about a call (timestamped) that you possibly ever need.
ResetCDR() is your friend. I use this now so that I can track the original call duration and the portion of the call after it's transferred by the called party. This actually creates a second CDR record and should then contain the billsecs to match the conversation time.
Not 100% sure on all that but, give it a whirl, I think it's what you want.
http://www.voip-info.org/wiki/view/Asterisk+cmd+ResetCDR
might be too late to answer your question, but I have the exact same scenario.
What I did is, just before the call is forwarded to the C leg (A leg is caller, B leg is IVR who answers the call, C leg is destination where to forward the call), use ForkCDR(arve).
Something like:
exten => _X.,1,NoOp(Incoming call from Provider X to User Y)
same => n,Macro(Execute_IVR)
same => n,ForkCDR(arve)
same => n,Dial(SIP/${EXTEN}#userY)
And it works fine: I get 2 CDR rows, one for A leg to IVR with its own bill sec (say, 25 seconds), and the other one with call forwardinng A leg to C leg, also with its own billsec (say 350 seconds).
The sum of the 2 billsecs gives you the total duration of the call placed by A leg (caller).
The billsec of the second CDR gives you the conversation duration of that part of the call.

How to Asterisk dial an extension on the same channel?(without bridging)

I am using a 8-port Asterisk card. I have a PBX. I want to call extension "222" from 1 channel(DAHDI/1-1) , i can do it using
exten =>s,1,Dial(DAHDI/3-1/222)
it use channel 3 as a bridge. However I want to dial "222" directly.
Actually i will use it for this senario:
A is customer
B is call center member
C is asterisk agi which I use credit card payment on phone line.
A calls B
B take infomations of A then
B tranfer A to C (Dial 111 on the phone)
A finish conversation with C (make payment succesfully)
Then I want to reconnect A and B (dialing B's caller ID (112))
You need create dialplan which will record B(extension) and transfer A to C, after that transfer back A to B(recorded in variable).
However all that still will use channels on card. You can't call not using channels.

Asterisk system ignore some DTMF digits when it called by PABX phone

I am using Asterisk E1 card on CentOS 6.2.
When I call on my asterisk system using a simple pstn or by a mobile phone, the call perfectly run. But when the same number has called by a PABX phone, the asterisk system ignored some digits.
I am using asterisk 1.4 and dahdi 2.4.
I have also tried the dtmfmode = rfc2833 in the sip.conf file. Please some one hemp me resolve this problem.
eg: What actually Our system do, when some one call on our system, we ask for for a 14 digit registration id, and perform some operation on it and it work fine. But when some one call from their own PBX phone (or PABX or soft phone) and enter the registration id, then our system ignore some digits.
I also had this problem some times ago this some PBXs.
this help for me:
relexdtmf=yes
Example of my channel.conf:
; SPAN 1-4 = E1 (1-15,17-31,32-46,48-62,63-77,79-93,94-108,110-124)
; ------------------
switchtype = euroisdn
; Type of Number (TON) for called number
pridialplan = local
; Type of Number (TON) for calling number
prilocaldialplan = private
signalling = pri_cpe
context = incoming
group = 1
immediate = no
overlapdial = yes
channel => 1-15,17-31,32-46,48-62,63-77,79-93,94-108,110-124
; activate this option if there are problems with dtmf detection
relexdtmf=yes
I suppose you meant 'call from PBX internal extension' from 'call from their own PBX phone'.
I have faced issue like this. In my case the issue was with the phone. some old or broken IP phone failed to generate proper DTMF signals. Have you tried different phones like soft phones.

Resources