Unique id for all channels associated with a call?

Hello experts,

Is there any way to get some kind of Unique ID for all channels associated with a call (association is done with bridge / dial action). In our application layer, when we receive the events for Channels from AMI, we need to fetch some sort of UNIQUE id from them. Is there a way to somehow set it through dialplan rather than changing asterisk code base?

NOTE: initially we progressed based on the Uniqueid from the ami event. However, later we found out the unique id is based on the time stamp and it gets changed between channel involved in a single call. Now our solution is doomed and we need a quick workaround for this. Any idea will be very much appreciated.

Thanks.

Asterisk doesn’t really have the concept of a call, and in the extreme case features like Park, Bridge and ChannelRedirect means you can conceive of cases where calls merge into each other to the extent that every channel in the lifetime of a switch is related to all the others.

You can, of course, set channel variables that inherit across channel creations (but not across explicit bridging or unparking.

As you are already using AMI, I’d suggest using that to add an identifier for whatever you class as a call to the channel. For simple cases, using a variable with two initial underscores may be enough.

Also note that unique IDs identify channels, i.e. legs of a call, and they are opaque IDs. They happen to contain the time and a serial number, but that is simply a tactic to ensure that they are unique for that switch.

Hi David,

Thank you very much for your reply. It really cleared my concept.

“Also note that unique IDs identify channels, i.e. legs of a call, and they are opaque IDs. They happen to contain the time and a serial number, but that is simply a tactic to ensure that they are unique for that switch.”

— Can you elaborate this a bit? If there is no concept of Call in the system, Does it mean that every channel can have its own unique id?

ext1 —> dial 009 —> asterisk context --> Dial(009) --> ext2

in this case, ext1 dials 009 (ext2), I can see that ext1 channel & ext2 channel can have the same unique-id, but this is not true for all call scenario. Does it mean that I can not rely on the unique Call ID atall to identify in my Application layer that ext1 & ext2 have the same unique-id ?

Every channel must have its own Unique-ID. That is the whole point of uique IDs. The channel name is not unique in time.

You diagram only shows two channels. One channel attached to the callee and one channel attached to the called party.

If you set a channel variable with __ in front of the name for the channel associated the incoming call from device (not really extension) 1, the DIal application will copy it to the channel associated with the outgoing call to device 2.

You will have to explicitly read the variable.

Hi David,

Thanks a lot for your explanation. Now that I understand the uniqueid can not be used as a link between call legs, I am trying to use channel variables. I am using OriginateAction . But it seems like the channel variable i’m trying to set “_VU” does not propagate to the other call-leg! I am trying to set the ‘variable’ in the OriginateAction.

Is it supposed to be propagated or am I doing something wrong?

Regards,
Sajid.

Try two underscores.

Hi David,

Thank you very much for all your support. Your suggestion helped me resolve most of the asterisk migration issue I had. I was trying with two __ but I didn’t realize that you need to only use the VarName without the underscore when trying to ‘getVar’ for that variable.

Thanks again.