Call forwarding using asterisk

Can anyone suggest set up for call forwarding using asterisk ? How can I do this ? I am using asterisk 13. Regards.

Since I see you’re using realtime, store the extension in a database with a field for the forward number. Query that table from the dialplan. If there’s a number in the field, send the call to it, if not, send it to the extension. I have mine set up with a table containing multiple records. My users can choose between a list of forwards. They can leave the forward number selected for the cases where it’s forwarding from a queue or auto-attendant. They have another flag for On/Off. On turns the forward on immediately. Off only forwards when the endpoint is not available.

@mkozusnik Thank you for reply.I am using extensions.lua.Can you please elaborate how can I give multiple forwards ? I am new for this.Can you please explain in detail ? Are you using GUI for that ? I have no GUI related to that.Regards.

Yes, I created a web-based GUI to manage all of the functions build into my asterisk system. Underneath, however, it’s just a database. The web app allows us to enter a list of forwarding numbers that the users can log in to and choose to attach to an extension, queue, auto-attendant, etc. I don’t use lua, but from the dialplan (conf file), I query my extensions table to see if a forward has been selected. If it has, I send the call to the forward number. If not, I send the call to the extension (device).

Here is the relevant code I use:
The subInternalDialer and subInternalDIDDialer just check a few thinks, and send the call out.

[from-pstn]
;Inbound from the PRI Gateway
exten => _X.,1,NoOp(Call from ${CALLERID(all)} to ${EXTEN})
same    => n,Set(dialed=${EXTEN})
same    => n,Set(ARRAY(cluster,ext,devicetype,devopt,outcidname,outcidnum,vmbox,findfollow,lockout,sectodial,forwardflag,forwardnum,recordcall,recordemail,ringtone,hotdesk_ext)=${ODBC_READSQL(select ext_cluster\, ext_dialed\, ext_dev_type\, ext_options\, ext_outbound_cid_name\, ext_outbound_cid_num\, ext_vm_box\, ext_findfollow\, ext_lockout\, ext_seconds_to_dial\, ext_forward_flag\, ext_forward_num\, ext_record\, ext_record_email\, ext_distinct_ring\, hotdesk_ext from extensions left outer join hotdesk on hotdesk_device_id=ext_dialed where ext_did like '%${EXTEN}' or ext_dialed like '%${EXTEN}')})

...

;;;Call forward
same    => n(noblacklist),GotoIf($["${forwardflag}" = "1"]?callforward,${forwardnum},1)

...

[callforward]
exten     => _ZXX,1,GoSub(subInternalDialer,s,1(${forwardnum}))
exten     => _ZXXX,1,GoSub(subInternalDialer,s,1(${forwardnum}))
exten     => _ZXXXX,1,GoSub(subInternalDialer,s,1(${forwardnum}))
exten    => _NXXNXXXXXX,1,GoSub(subInternalDIDDialer,s,1(${forwardnum}))
exten    => _1NXXNXXXXXX,1,GoSub(subInternalDIDDialer,s,1(${forwardnum}))
exten    => _9NXXNXXXXXX,1,GoSub(subInternalDIDDialer,s,1(${forwardnum:-10}))
exten    => _91NXXNXXXXXX,1,GoSub(subInternalDIDDialer,s,1(${forwardnum:-11}))

exten    => _X.,1,Answer()
same    => n(invalidext),Playback(like_to_tell_valid_ext)
same    => n,Hangup()

exten    => i,1,Hangup()
exten    => t,1,Hangup()
exten    => h,1,Hangup()
1 Like