Is it possible for asterisk to send a 500 to voip provider?

My provider auto routes calls to my mobile if my asterisk server is unavailable (due to network problems etc).

Is it possible to send an unavailable signal back to them if my sip phone is unavailable?

I ask because I set up a dial plan to dial out if device is unavailable, but that shows the caller ID as being my home number instead of the caller’s number.

Actually a solution to either would be useful.

*Edit: actually my dial out plan isn’t working.

500 is server broken, not user unavailable.

By passing an appropriate hangup cause to the Hangup application (before answering the call) you should be able to generate a not available status. In theory, 20 should do it (which you will get if your phones register and you simply turn them off.

The full translation from ISDN cause codes to SIP ones is in the source code. It mainly follows the corresponding RFC.

Some dialplans answer prematurely and you would need to avoid that.

I’ll have to experiment with different codes I think. I tried 20 and some others and I get a busy signal back.

The settings that draytel uses are ‘on offline’ and ‘on busy’ which I can forward to another number or go to voicemail etc. But even though I get a busy tone back it doesn’t forward.

This is what I’m following at the moment: voip-info.org/wiki/view/Aste … angupcause

Thanks for help. It’s pointed me in the right direction.

Incidently, if asterisk can Dial() a number or Originate() a number, is there any way of getting asterisk to transfer the call normally, because all I seem to be able to do is ring and then hangup right after?

Looking up Transfer() didn’t really help.

Edit: Fixed - I was use ExecIf instead of GotoIf

Transfer is the way of doing it. It’s error handling is not very good though, and I suspect most ITSPs wll not honour it. Those that do, will probably charge you for an outgoing call.

Transfer behaves differently depending on whether or not the call has been answered. I would expect ITSPs are more likely to cope with a transfer before answer.

Note. I rather suspect you are answering the call. That can be done by various applications, not just a successful Dial.

This is my dial plan:

exten => s,1,NoCDR() exten => s,n,NoOp(-------- ${DEVICE_STATE(SIP/android)} ---------) exten => s,n,GotoIf($[${DEVICE_STATE(SIP/android)} = UNAVAILABLE]?outoftown) exten => s,n,Set(DYNAMIC_FEATURES=automon) exten => s,n,Set(TOUCH_MONITOR=${CALLERID(num)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M)}) exten => s,n,AGI(call-log.agi) exten => s,n,Dial(SIP/android,20,wW) exten => s,n,Playback(vm-nobodyavail) exten => s,n,Voicemail(dave@default) exten => s,n,Playback(vm-goodbye) exten => s,n,Hangup() exten => s,n(outoftown),Transfer(SIP/0xxxxxxx@draytel)

All I get is a busy tone and this is he console output:

-- Executing [s@incoming:1] NoCDR("SIP/draytel-00000000", "") in new stack -- Executing [s@incoming:2] NoOp("SIP/draytel-00000000", "-------- UNAVAILABLE ---------") in new stack -- Executing [s@incoming:3] GotoIf("SIP/draytel-00000000", "1?outoftown") in new stack -- Goto (incoming,s,12) -- Executing [s@incoming:12] Transfer("SIP/draytel-00000000", "SIP/0xxxxxxxxx@draytel") in new stack -- Auto fallthrough, channel 'SIP/draytel-00000000' status is 'UNKNOWN'

The fallthrough is normal.

The address for the transfer must be in the form used by the upstream system. You can’t use sip.conf section names.

As the call does not seem to have been answered, Asterisk will have terminated the incoming call, but the ITSP may or may not honour the associated transfer.

I’ve been in touch with my voip provider and tested a few times for them. Now using a Hangup(17) will forward to my mobile, which is fine. There is still an issue with the caller ID as showing as coming from me rather than the source and I’m waiting for them to get back to me about that. The only options in my ITSP’s dial plan are to use my number or blank.

Well the Caller ID will always be fixed to my number it seems. I’ve changed the hangup code to 20 and for what it’s worth it now looks like this:

exten => s,1,Set(DYNAMIC_FEATURES=automon) exten => s,n,Set(TOUCH_MONITOR=${CALLERID(num)}-${EXTEN}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M)}) exten => s,n,AGI(call-log.agi) exten => s,n,Dial(SIP/android,20,wW) exten => s,n,NoOp(-------- ${DEVICE_STATE(SIP/android)} ---------) exten => s,n,GotoIf($[${DEVICE_STATE(SIP/android)} = UNAVAILABLE]?outoftown) exten => s,n,Playback(vm-nobodyavail) exten => s,n,Voicemail(dave@default) exten => s,n,Playback(vm-goodbye) exten => s,n,Hangup() exten => s,n(outoftown),Hangup(20)

Putting the DEVICE_STATE after the dialling attempt gets the correct state. When it was before it, it would show as NOT_INUSE for the first attempt and then UNAVAILABLE for consequential attempts.