Checking if a call has been forwarded

Hello,
is it possible to check, if an external call has been forwarded? I have seen the FORWARDERNAME variable, checked it. It is empty when a dialed external number forwards a call.

In my case it is also empty if Asterisk itself forwards calls to the outside (diversion information is set by a macro).

The REDIRECTING dialplan function[1] can be used to get redirecting information, which would be set if redirected I would expect. Otherwise you’ll need to show console output so it can be seen precisely what is happening.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+17+Function_REDIRECTING

I have read somewhere (maybe in sources), that redirecting cannot call simultaneously to multiple phones. Can I make simultaneous calls with the diversion header using this function?

REDIRECTING doesn’t control the calls; it only provides information.

I don’t think any of the actual signalling systems that support redirection information support passing information about more than one destination.

[ SIP seems to only report the redirector, and, although the syntax seems to allow multiple URIs, I’m not sure how that would work in practice. ]

By multiple calls I mean calling {phone}&{phone} in one dial command. Sometimes I need to redirect calls to a group of external phones at once.

That is supported and works fine.

What you are not going to get, in that case, is redirecting information sent to the caller (single is the boolean that indicates that the & feature is not being used):

if (single && !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)) {
			struct ast_party_redirecting redirecting;

			/*
			 * Redirecting updates to the caller make sense only on single
			 * calls.
			 *
			 * We must unlock c before calling
			 * ast_channel_redirecting_macro, because we put c into
			 * autoservice there.  That is pretty much a guaranteed
			 * deadlock.  This is why the handling of c's lock may seem a
			 * bit unusual here.
			 */
			ast_party_redirecting_init(&redirecting);

I think the above is the code for signalling redirecting when the initial outgoing call was to multiple destinations. It’s a long time since I tried out redirecting, but I’m fairly sure that it works in terms of Asterisk extensions, not endpoints (even though many people confuse them). If that is correct, a redirect to an extension that then dials numbers in parallel will be reported as a redirection to that extension, not any of the endpoints or numbers that are called as a result.

[ Although the Asterisk core seems to capture both original and target information, SIP doesn’t seem to support sending the new destination back upstream. ]

My typical scenario is as follows: I accept a call to a single phone, then a call goes through IVR and then I must redirect it to external phones. I can either call external phones one after another or simultaneously. Thus is done in form of redirection.

The diversion header, provided by the REDIRECTING function, is unfortunately not complete.It has only reason and phone. Is there a chance to set the privacy mode? Also, I do not remember if Asterisk supports original called number (two diversion headers in invites). When I set up my Asterisk, I was required to make the diversion header with privacy and other keys. I will try REDIECTING function tonight.

The example with the REDIRECTING function at page https://wiki.asterisk.org/wiki/display/AST/Manipulating+Party+ID+Information#ManipulatingPartyIDInformation-REDIRECTINGdialplanfunction states, I should set the REDIRECTING(to-num,i) parameter. How to set it, if I have 2 phones at once to call to in the DIAL command? Is this parameter necessary for PJSIP?

You don’t. When a call is forwarded it is sent to a single extension in the dialplan, which then executes whatever is stated in the dialplan. It doesn’t dictate what the Dial() command directly does, merely that a call goes to a particular place in the dialplan.

I’m still over all confused over what exactly you are trying to achieve, but that could just be my lack of seeing an advanced use case.

The dial command is able to call multiple phones. I need to call multiple phones with a diversion header.

That sounds like a proposed solution to a use case, rather than the actual use case.

Also, simply expanding a call to multiple devices is not not normally diversion; it is normally part of the first choice routing.

That acts like a queue, when all agents are simultaneously rung. They work on remote phones that can be reached with redirecting (without diversion calls will be blocked).

OK, thank you for help.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.