How to save Remote Party ID to CDR in Asterisk? - 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.

Related

How to get actual number of channel in asterisk 13?

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.

How to get EDI 997 instead of TA1 in BT2010?

I'm testing (simulating receipt) of PO/850 on BizTalk 2010 by dropping an EDI in a file receive. I get two files output, one is a TA1 and one is the 850. (In the real world, I will send the 997 back to the party that sent me the 850.)
I have a Send Port defined to go to file system, with filter:
BTS.ReceivePortName == rp_partner_850. In the directory associated with that SendPort is where I see both the 850 and the TA1.
In the Party/Agreement in BTAdmin, on the Parter->MyCompany tab, then the "Acknowledgments" section, I have checked "997 expected" and not checked "TA1 Expected".
I'm also unclear why I need to select the "Send Ports" in the Party/Agreement tool. How does that interplay with filters on the Send Ports.
I tried setting up a second send port to a second disk directory, and on that one I set filter to this: BTS.MessageType == http://schemas.microsoft.com/Edi/X12#X12_997_Root, as per this question.
I made quite a few changes, so not sure exactly which one got it working. I followed videos 2-4 found here: https://msdn.microsoft.com/en-us/biztalk/gg153513
I'm still getting the TA1s, and will work on that next, but now I'm getting 997s in a separate SendPort.
I added new send port sp_997_Test with the filter as described in the question above, and specified that in the "MyCompany->Partner" tab of the agreement under Send Ports.
I also setup the "Local Host Settings" on the "Partner->MyCompany" and put "850-Purchase-Order..." in the ST1 column, and the Partner Value in the GS2 column.

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 ;)

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.

Dynamics AX 2009 AIF Tables

Background
I have an issue where roughly once a month the AIFQueueManager table is populated with ~150 records which relate to messages which had been sent to AX (where they "successfully failed"; i.e. errorred due to violation of business rules, but returned an exception as expected) over 6 months ago.
Question
What tables are involved in the AIF inbound message process / what order to events occur in? e.g. XML file is picked up and recorded in the AifDocumentLog, data's extracted and added to the AifQueueManager and AifGatewayQueue tables, records from here are then inserted in the AifMessageLog, etc.
Thanks in advance.
There are 4 main AIF classes, I will be talking about the inbound only, and focusing on the included file system adapter and flat XML files. I hope this makes things a little less hazy.
AIFGatewayReceiveService - Uses adapters/channels to read messages in from different sources, and dumps them in the AifGatewayQueue table
AIFInboundProcessingService - This processes the AifGatewayQueue table data and sends to the Ax[Document] classes
AIFOutboundProcessingService - This is the inverse of #2. It creates XMLs with relevent metadata
AIFGatewaySendService - This is the inverse of #1, where it uses adapters/channels to send messages out to different locations from the AifGatewayQueue
For #1
So #1 basically fills the AifGatewayQueue, which is just a queue of work. It loops through all of your channels and then finds the relevant adapter by ClassId. The adapters are classes that implement AifIntegrationAdapter and AifReceiveAdapter if you wanted to make your own custom one. When it loops over the different channels, it then loops over each "message" and tries to receive it into the queue.
If it can't process the file for some reason, it catches exceptions and throws them in the SysExceptionTable [Basic>Periodic>Application Integration Framework>Exceptions]. These messages are scraped from the infolog, and the messages are generated mostly from the receive adaptor, which would be AifFileSystemReceiveAdapter for my example.
For #2
So #2 is processing the inbound messages sitting in the queue (ready/inprocess). The AifRequestProcessor\processServiceRequest does the work.
From this method, it will call:
Various calls to Classes\AifMessageManager, which puts records in the AifMessageLog and the AifDocumentLog.
This key line: responseMessage = AifRequestProcessor::executeServiceOperation(message, endpointActionPolicy); which actually does the operation against the Ax[Document] classes by eventually getting to AifDispatcher::callServiceMethod(...)
It gets the return XML and packages that into an AifMessage called responseMessage and returns that where it may be logged. It also takes that return value, and if there is a response channel, it submits that back into the AifGatewayQueue
AifQueueManager is actually cleared and populated on the fly by calling AifQueueManager::createQueueManagerData();.

Resources