Call Deflection via SIP 302 "moved temporarily"

Hello!

Our telephone provider supports Call Deflection with SIP 302 “moved temporarily”. And it works perfectly with our old telephone system.

Unfortunately, I have not been able to get any further when trying to set it up with FreePBX. In my search there are many results for the old SIP driver, but hardly anything for PJSIP. Sometimes it says that in principle it should work automatically, someone else suggests using dialplan hooks (without saying exactly how).
And then there’s this open bug report about an incorrect header for SIP 302, which apparently requires a supplied patch: ASTERISK-30451: res_pjsip: Contact header set incorrectly for call redirect (302 Moved temp.) when external_* set
(But I really don’t want to install a self-compiled Asterisk in FreePBX…)

Can anyone comment on whether call deflection is feasible with FreePBX and PJSIP?
Or whether it is actually due to this bug?

For all those who don’t know what this is actually about: With call deflection, call forwarding is not carried out by the telephone system itself, but only the destination number is transmitted. This means that no valuable SIP channels are occupied.

Translated with DeepL.com (free version)

I believe you need to use custom dialplan, as you need to use the Transfer application (before the call is answered). I think the required Transfer application parameters are:

Transfer(PJSIP/sip:<user>@<domain>)

where user would normally be the redirected phone number and domain would normally be that from the server setting.

Limits on the number of simultaneous calls are a commercial constraint; SIP doesn’t limit the number, and it is only the underlying IP bandwidth that is limited. Many providers won’t accept redirects, and, at least in theory, they could include redirected calls in the the limit on simultaneous calls.

Thank you for your answer!
But the explanation is too short for me to be able to do anything with it.
Unfortunately, I have no idea where I have to add the transfer command so that only calls for which call forwarding is activated are forwarded.

Did you actually tried something like that?

I’ve only done this sort of thing with raw Asterisk, and only with chan_sip.

As far as I know it is a power user change for FreePBX, so you really need an understanding of custom dialplans, and how FreePBX works, to be able to do it in a way that will be maintainable.

In any case, there isn’t enough information on your exact use case to be able to fill in the design details in a way that is sure to cover your intended usage.

You can transfer using pjsip (including 302 redirect if the call has not yet been answered); see

However, this is generally a good idea only if you are sending the call to an external answering service, your headquarters, or another destination that will reliably answer and log the call.

If forwarding to a personal mobile or home phone, transfer is usually undesirable, as the call could end up in personal voicemail or an error announcement (unreachable, etc.) Also, you won’t be able to record the call, transfer it further, have a record of its duration, or even know whether it was ultimately answered.

If your provider’s contract charges per minute for both incoming and outgoing calls, you will still be charged for both legs of a redirected call. Also, with such arrangements the number of channels is just an administrative setting and can probably be increased as desired at no additional cost.

OTOH, if you get ‘unlimited’ domestic calls, you are paying a monthly charge per channel; increasing the limit will incur additional monthly charges. However, in this case the provider will almost certainly count redirected calls against your channel limit.

Hi David!

My use case is quite “normal”. I have a (PJSIP) sip trunk to my phone provider. And PJSIP extensions for user phones.
And when a user activates call foward (to his cell phone for example), the PBX should do that via call deflection, instead of using two phone lines.

I have a basic understanding of the dialplan, although it is still not my best friend… :slight_smile:
But I’m unsure yet where to modify it.

Did you use one of the dialplan hooks? Or do I have to use the context from the sip trunk?

You may want to read Asterisk crashes on Transfer function with tel: URL - Asterisk SIP - Asterisk Community as, as well as some information on how to code it, it mentions two possible bugs, neither of which has been formally reported. One may make 302 incompatible with being behind NAT.

Thanks, maybe that will help.
The guy from this thread uses “Goto (external-transfer-out,s,1)”, but unfortunately he didn’t tell where he put that.

But that is still one of my biggest riddle. I don’t want to mess up the whole dialplan for that.

That seems very difficult, because nobody can’t tell me that.

There was a recent thread that shows a solution:

However, IMO it’s not a good idea for your use case.

What problem do you see using two phone lines? Why do you even want a cellular voice call, rather than using a SIP app on the mobile?

Also, note that using call forward this way is error prone: users forget to turn on forwarding when they leave the office or are temporarily away from their desk, and forget to turn it off when they return (until their mobile unexpectedly starts ringing). A better solution is Follow Me, always active, that starts ringing the mobile if the desk phone is not answered quickly.

What problem do you see using two phone lines?

In our country, the telephone companies are unfortunately quite stingy when it comes to the number of simultaneous calls. That’s why I don’t want to be unnecessarily wasteful.

Why do you even want a cellular voice call, rather than using a SIP app on the mobile?

Firstly, I don’t want to share the telephone system with the public Internet.
And an extra SIP app on the cell phone might be something for me, but some of our users would probably find it difficult.

And a “follow me” doesn’t solve the real problem with the limited number of calls that can be made at the same time. As soon as someone calls, this also uses two lines.

Sure, in any country if you have a plan where there is no per-minute charge for domestic calls, you pay a fairly steep monthly charge for each channel. Once the channel limit is reached, further incoming calls get a busy signal and outgoing call attempts are rejected. However, first check with your carrier – they are likely to count redirected calls against your channel limit, in which case doing redirect won’t help.

In most of the world, VoIP apps are very popular and most users already have at least one: WhatsApp, FaceTime, Line, WeChat, Signal, Telegram, Skype, etc. An additional VoIP app shouldn’t be a problem. However, if you are in a country where these apps are blocked or even illegal, then I agree that a SIP app is unsuitable.

Good security is of course difficult. But if you have secure remote access for other purposes (employees working from home, intranet access for select customers and vendors, connections to branch offices, etc.), then you can use the same VPN or other technologies to secure phone connections. Also, if you are forwarding voice calls to cellular to avoid these security issues, be aware that properly securing DISA is also difficult.

I know this answer won’t be very helpful. I tried to implement call deflection in FreePBX/Asterisk once and I couldn’t make/find a working solution back than. I ended up by just buying more channels from our provider.

Our provider counts redirect but instead of using two channels (one inbound and one outbound) with call deflection it just gets counted as one used channel by the provider. So I can understand why OP wants to implement this.

Thanks Jonathan!
Your answer at least helps me morally!
I no longer feel completely stupid. :slight_smile:

This is not Redirecting the call, this is answering the call on the system and transferring it to the PSTN trunk endpoint. This is no different than you answering the call and hitting the transfer button to send the call to a new destination.

There is an actual process for redirecting calls for something like this:

Manipulating Party ID Information - Asterisk Documentation

Edit: The dial command is also incorrect, you need to specify the outbound endpoint the call is going over with PJSIP.

The Transfer application is very much redirecting and it doesn’t answer the call.

If the call has not been answered, it sends a 302 response, with the URI as the Contact header.

If the call has been answered, it sends a REFER request, with the URI as the contents of the Refer-To header.

Obviously it has to be run on the actual incoming channel, so won’t work if, for example, FreePBX has interposed a local channel.

I think you are being confused by the fact that people refer to “transferring” a call when they are actually talking about making a tandem connnection.

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