How to detect 181 Call Is Being Forwarded

I have this sequence in one of my trunks:

Asterisk SIP provider
<- 100
<- 183
<- 181
<- 181
<- 200
ACK ->

I’m placing the call using the originate command, and using asterisk 1.8. How can I get notified about the existence of 181 messages occurred before the 200 ? Can I receive this information in the dialplan itself ? Thx.

181 cannot happen after 200 and your example does not show that.

If one before the 200 can be detected, it will be in terms of connected party updates, so I would check if associated functions (probably REDIRECTING) provide the information. Otherwise, you will be out of luck. (I’m using an older version, so I am not familiar with exactly what conditions are required for these to work.)

Thx for your answer. I check the docs, maybe can I get what i want using this macros ?


I searched for the way to use this inside my dialplan without success. Can someone point me in the right direction ?

I made some progress here, but i still need help. I changed the originate to use a local channel, like this:

[from-local] exten => 3000,1,Set(REDIRECTING_CALLER_SEND_MACRO=caller) same => n,Dial(SIP/sipp/4004711881,30,t)
The outgoing call is made, and the REDIRECTING_CALLER_SEND_MACRO is called when that side it receives 181. What I need now is pass this “information” to the call on 3001@tts; so that side can decide to continue with the call or not. Setting variables doesn’t work. They exist on one side of the local channel, but doesn’t in the other. How can I pass this info to the other side ?

Variables beginning _ will be passed when the channel is created. Otherwise, you need to use global variables. (I’m assuming that your strategy is optimum, rather than doing a deep analysis.)

I learn about shared variables, and think that maybe the way. Since it’s a unrelated topic i will do another post for that. Thx for your help.