asterisk call forwarding

Home » Asterisk Users » asterisk call forwarding
Asterisk Users 8 Comments

Thank you so much that solved my database issue. Now how asterisk will
forward call ?

Or I need to specify gotoif statment in my stdexten to check database
key and take action?

8 thoughts on - asterisk call forwarding

  • On Tue, 3 May 2011 18:10:55 -0400
    Satish Patel wrote:

    Yes, you need to write the dialplan to act on the key. There is a
    sample out there somewhere (I’ve seen it) that uses the same CFIM
    database keys that you’re setting. Wherever you got the code to set
    those keys, you should be able to find the code for reading and acting
    on them…

  • Hey!

    I tried your statement but its not working but if i insert manually it works

    exten => *72,10,Set(DB(CFIM/${fromext})=${toext})

    at CLI

  • Hi I have to setup call forwarding. How do we setup Call forwarding in asterisk?. Eg. user dials a number and insert some mobile number for forwarding and dial another number to cancel the forwarding. thanks a lot.

    Best Regards,


  • I implemented this like so in my default context:

    exten => _*21.,1,Answer()
    same => n,GotoIf($[“${CALLERID(num)}”=”“]?divert:void)
    same => n(divert),Set(DB(divert/${CALLERID(num):-4})=${EXTEN:3})
    same => n,Gosub(divertactive,1)
    same => n,Hangup()
    same => n(void),Gosub(divertvoid,1)
    exten => _#21,1,Answer()
    same => n,GotoIf($[“${CALLERID(num)}”=”
    same => n(divert),Verbose(0,${DB_DELETE(divert/${CALLERID(num):-4})})
    same => n,Gosub(divertoff,1)
    same => n,Hangup()
    same => n(void),Gosub(divertvoid,1)

    (note: use whatever you need in the GotoIf to validate that the phone the call is from is permitted to set up call forwarding – unless you’re allowing it for all that can reach the context)

    The divert{off,active,void} subroutines are where I handle the announcements – but you could probably easily implement your own.

    At the top of my [voicemail] context, I do this:


    (ARG3 contains the last four digits of the number the call came to in my case, and a success passes the call via the “outbound-standard”
    context which is in my dialplan. Your exact requirements may vary but this may help.)

  • Hi,

    Thanks Phil, I will implement this and get back to you.

    Best Regards, Madushan

  • Hi

    What is redacted means?

    same => n,GotoIf($[“${CALLERID(num)}”=”**”]?divert:void)

    Thanks Best Regards, Madushan

    On Thu, Mar 3, 2016 at 10:58 PM, Madushan Geethanga

  • Censored. Ususally for political reasons. In this case, the OP didn’t want to put a real phone number in a public list.