In-call feature code to send a call your other extension

In fact, the *37 feature code already works on external channels, but the dialplan bails if no valid ampuser is found from the channel name.

It’s actually not difficult to preserve the AMPUSER value on the external channels, I’ve updated post 1 to do this. In its present form I am able to:

  1. Answer a call on my local extension
  2. flip the call to a group of numbers using FMFM
  3. answer the call on my mobile
  4. flip the call back to the same group of numbers

EDIT: There is a better way to do this though, I’m reverting the change to post 1

Here is my work in progress:

[move-active-call]
exten => s,1,Noop(Entering user defined context move-active-call in extensions_custom.conf)
 exten => s,n,DumpChan  ; uncomment for debug

; get ampuser from initiating channel but skip if we have we run this gosub before
exten => s,n,GotoIf($["${LEN(${MOVING_AMPUSER})}"!="0"]?skip)
exten => s,n,GotoIf($["${LEN(${PICKUPMARK})}"!="0"]?skip)

exten => s,n(continue),Gosub(get-AMPUSER-from-asterisk-channel,s,1(${DYNAMIC_WHO_ACTIVATED}))
exten => s,n,ExecIf($["${GOSUB_RETVAL}"=""]?Return)   ; abandon if no matching ampuser is found, also works for security as won't work for external channels
exten => s,n,Set(MOVING_AMPUSER=${GOSUB_RETVAL})     ; preserve result for downstream channels

exten => s,n(skip),Noop(Trying to move ${BRIDGEPEER} to another device for extension ${MOVING_AMPUSER})
; Originate call to all local devices, they will ring for 15s 
exten => s,n,Originate(Local/${MOVING_AMPUSER}@originate-skipvm,exten,move-active-call,take_call,1,15,ac(${CALLERID})v(bp=${BRIDGEPEER}^__MOVING_AMPUSER=${MOVING_AMPUSER}))
exten => s,n,Return

exten => take_call,1,Noop(Bridging the call)
exten => take_call,n,Bridge(${bp},x)
1 Like

Ken here’s something better:

[move-active-call]
exten => s,1,Noop(Entering user defined context move-active-call in extensions_custom.conf)
; exten => s,n,DumpChan  ; uncomment for debug
exten => s,n,Gosub(get-AMPUSER-from-asterisk-channel,s,1(${DYNAMIC_WHO_ACTIVATED}))
exten => s,n,ExecIf($["${GOSUB_RETVAL}"!=""]?Set(MOVING_USER=${GOSUB_RETVAL})    ; will set if local channel initiates
exten => s,n,ExecIf($["${PICKUPMARK}"!="" & "${GOSUB_RETVAL}"=""]?Set(MOVING_USER=${PICKUPMARK})        ; will set if external channel was created via fmfm
exten => s,n,GotoIf($["${MOVING_USER}"=""]?end)                                  ; if all else fails use the value we already have

exten => s,n,Noop(Trying to move ${BRIDGEPEER} to another device for extension ${MOVING_USER})
; Originate call to all local devices, they will ring for 15s 
exten => s,n(call-setup),Originate(Local/${MOVING_USER}@originate-skipvm,exten,move-active-call,take_call,1,15,ac(${CALLERID})v(bp=${BRIDGEPEER}^__MOVING_USER=${MOVING_USER}))
exten => s,n(end),Return

exten => take_call,1,Noop(Bridging the call)
exten => take_call,n,Bridge(${bp},x)

GIve this a workout, I shall hold off on updating post 1 until we get an all clear.

With this you can use the diaplan like you normally would from local channels, but you can also initiate the feature code from any remote channel that was setup using FMFM. You don’t need to answer the call locally first.

Edit - Post 1 updated

If you call this feature code from a local extension that has DND enabled then things just fail silently. Unfortunately I see no mechanism to override DND and allow the call to proceed. One would have to have a custom originate context that checks the AstDB, sets the current value and adds a hangup handler to reset it back when you’re done. My former coworker would say ‘the juice ain’t worth the squeeze’.

This works like a champ. Not concerned about the DND aspects. I’ll have to play with a hard phone to see if I can do a memory dial button to dial the *37.

Edit: A speed dial button with *37 on the hard phone works great.

1 Like