Need get dstchannel after dial to use in another macro

Hi, I need to get the ${CDR(dstchannel}) after Dial command (macro-dialout-trunk)

I set a custom destination for my custom context, but in this context i need the dstchannel of the call, but the call was already hungup.

I setup on my outbound route in case of congestion, go to a custom context. Worked, but in this context i need the dstchannel variable of the call. I know that in this moment the call was gone, but there is way to set this variable after the “dial” to use in thist custom context ?


You could set the variable in the Asterisk database using a DBSet() while the call is active and DBGet() it after the call has terminated. You can also set global and local variables in your context that will survive the call.

No offense, but there’s a really good book called “Asterisk For Dummies” that covers how to write simple contexts (Chapter 6 or 8 IIRC). There are also about a million Wikis out there that can help you get to where you are going.

Hi, no offenses…i know how to write contexts.

But the problem is that to use any set variable or dbset that you said, i need to put on the current dialplan where the dial application is, wich is resided in macro-dialout-trunk … i tried to put a macro-dialout-trunk-custom, but didn’t worked. Tried using on macro-dialout-predial-hook, but its executed before Dial() so i dont have the dstchannel yet.

Use macro-dialout-predial-hook to add a hangup handler and use the hangup handler context to set the variable, or possibly to do everything you are doing in the custom destination.