Asterisk tips findme

Find-me / Follow-me example


Thus far every example of doing this dials one number at a time in series. If you have more than a couple numbers in your find-me list, this can keep a caller waiting for a long time.

By using the local channel construct in the Dial cmd you can dial a virtually unlimited number of find-me numbers in parallel and use a macro to determine which one actually has a live person at the other end.


[default]
exten => _9999XXXXXXXXXX,1,Dial(IAX2/"identifier"/${EXTEN:4},40,M(screen))
exten => _9999XXXXXXXXXX,2,Hangup

[macro-screen]
exten => s,1,Wait(1)
exten => s,n,Background(press-1-to-be-connected-to-the-caller)
exten => s,n,Set(TIMEOUT(response=5))
exten => 1,1,NoOp(Caller accepted) ; Do not set MACRO_RESULT to anything to connect the caller
exten => i,1,Set(MACRO_RESULT=CONTINUE)
exten => t,1,Set(MACRO_RESULT=CONTINUE)

[findme]
exten => s,1,Playback(please-hold-while-we-connect-you)
exten => s,n,Dial(LOCAL/9999${findme1}&LOCAL/9999${findme2}&LOCAL/9999${findme3},40,m)

Notes:

  • The 9999 is to distinguish the findme function from other ten digit extensions you may have in the default context
  • The LOCAL channel construct always calls into the [default] context
  • If you are dialing out on a channel that is connected immediately after dialing such as a POTS line, you will need to change your macro to loop the playing of the message otherwise the callee will never hear it.

Example:

Lets say you have 3 cell phones: (777)555-1111, (777)555-2222, (777)555-3333. You wish them to ring simultaneously when a call comes in. Put this somewhere in global section of extensions.conf:

findme1=(777)555-1111
findme2=(777)555-2222
findme3=(777)555-3333

  • Copy and paste above Macro screen and [findme] context as-si anywhere in extensions.conf.
  • Copy these lines in [default] above to your existing default context of your extensions.conf. Make sure to replace "identifier" with your IAX provider (or SIP provider). You may also want to make sure that the audio file exists in /var/lib/asterisk/sounds. If not, pick some other file. This is the message you will hear on your cell phone when asterisks calls you. You will need to press '1' to accept the call.

Works great. I configured this to dial my cell-phone and office number at the same time.

A slightly different example:

The original example has some problems with the original on 1.2.13 Asterisk (possibly others). Timeouts variables didn't seem work within a Macro. Instead the WaitExten app is called to accomplish the same thing.

Also, if the 'r' option isn't specified in the dial, it seems to pass a couple seconds of audio first

Additionally, if you just want the caller to hear ringing instead of a message, this example omits the "please wait" message to the caller


[default]
exten => _9999XXXXXXXXXX,1,Dial(IAX2/"identifier"/${EXTEN:4},40,rM(screen)) ; without r it seems to pass a second or two of audio first
exten => _9999XXXXXXXXXX,2,Hangup ; You can also substitute this with a Voicemail destination or other alternative destination

[macro-screen]
exten => s,1,Wait(1)
exten => s,n,Background(press-1-to-be-connected-to-the-caller) ; substitute a different playback file if you need to
exten => s,n,WaitExten(5) ; the value is the Wait time before we assume the call is not accepted
exten => 1,1,NoOp(Caller accepted) ; Do not set MACRO_RESULT to anything to connect the caller
exten => i,1,Set(MACRO_RESULT=CONTINUE)
exten => t,1,Set(MACRO_RESULT=CONTINUE)

[findme]
exten => s,1,NoOP(I'd rather the callers just hear ringing so they don't know they are calling something else)
exten => s,n,Dial(LOCAL/9999${findme1}&LOCAL/9999${findme2}&LOCAL/9999${findme3},40,m)


Combine Findme/Follow and AMD detection


I like very much the idea of sending a call to my cell. Letting my callers leave a message on my mobile phone company's mailbox, not so much. So I wrote this alternative, that will call my extension first. On no answer, will try my cell. Upon connection, a subroutine will be called: findmefollow-announce. I'm no fan of the "dial 1 to accept or 2 to reject" either, so I just had Festival tell me who is calling.

A word of advise with AMD, if you are indeed calling a cell or a phone in a noisy place, make sure you adjust the silence_threshold parameter accordingly (either in amd.conf or as a parameter of AMD()). In my case I changed it from 256 to 768, but it might take some playing around until you find the right setting for you.


[call-an-extension]
exten => s,1,Dial(SIP/12345,20,m)
exten => s,2,GotoIf($[${DIALSTATUS}" = "NOANSWER"]?3:4)
exten => s,3,Dial(SIP/5551212@voip-provider,30,$mU(findfollow-announce))
exten => s,4,Voicemail(12345@default)
exten => s,5,Hangup()

[findfollow-announce]
exten => s,1,Background(beep)
exten => s,2,AMD()
exten => s,3,Verbose(3,AMDSTATUS=${AMDSTATUS})
exten => s,4,Verbose(3,AMDCAUSE=${AMDCAUSE})
exten => s,5,GotoIf($["${AMDSTATUS}" = "HUMAN"]?6:8)
exten => s,6,Festival(You have a call from ${CALLERID(name)})
exten => s,7,Goto(9)
exten => s,8,Set(GOSUB_RESULT=CONTINUE)
exten => s,9,Return()


See also



Asterisk | Configuration | The Dialplan - extensions.conf | Dialplan Commands

This page has been viewed 57237 times since Tue 03 of Jan, 2006 (03:39 UTC)

Find-me / Follow-me example


Thus far every example of doing this dials one number at a time in series. If you have more than a couple numbers in your find-me list, this can keep a caller waiting for a long time.

By using the local channel construct in the Dial cmd you can dial a virtually unlimited number of find-me numbers in parallel and use a macro to determine which one actually has a live person at the other end.


[default]
exten => _9999XXXXXXXXXX,1,Dial(IAX2/"identifier"/${EXTEN:4},40,M(screen))
exten => _9999XXXXXXXXXX,2,Hangup

[macro-screen]
exten => s,1,Wait(1)
exten => s,n,Background(press-1-to-be-connected-to-the-caller)
exten => s,n,Set(TIMEOUT(response=5))
exten => 1,1,NoOp(Caller accepted) ; Do not set MACRO_RESULT to anything to connect the caller
exten => i,1,Set(MACRO_RESULT=CONTINUE)
exten => t,1,Set(MACRO_RESULT=CONTINUE)

[findme]
exten => s,1,Playback(please-hold-while-we-connect-you)
exten => s,n,Dial(LOCAL/9999${findme1}&LOCAL/9999${findme2}&LOCAL/9999${findme3},40,m)

Notes:

  • The 9999 is to distinguish the findme function from other ten digit extensions you may have in the default context
  • The LOCAL channel construct always calls into the [default] context
  • If you are dialing out on a channel that is connected immediately after dialing such as a POTS line, you will need to change your macro to loop the playing of the message otherwise the callee will never hear it.

Example:

Lets say you have 3 cell phones: (777)555-1111, (777)555-2222, (777)555-3333. You wish them to ring simultaneously when a call comes in. Put this somewhere in global section of extensions.conf:

findme1=(777)555-1111
findme2=(777)555-2222
findme3=(777)555-3333

  • Copy and paste above Macro screen and [findme] context as-si anywhere in extensions.conf.
  • Copy these lines in [default] above to your existing default context of your extensions.conf. Make sure to replace "identifier" with your IAX provider (or SIP provider). You may also want to make sure that the audio file exists in /var/lib/asterisk/sounds. If not, pick some other file. This is the message you will hear on your cell phone when asterisks calls you. You will need to press '1' to accept the call.

Works great. I configured this to dial my cell-phone and office number at the same time.

A slightly different example:

The original example has some problems with the original on 1.2.13 Asterisk (possibly others). Timeouts variables didn't seem work within a Macro. Instead the WaitExten app is called to accomplish the same thing.

Also, if the 'r' option isn't specified in the dial, it seems to pass a couple seconds of audio first

Additionally, if you just want the caller to hear ringing instead of a message, this example omits the "please wait" message to the caller


[default]
exten => _9999XXXXXXXXXX,1,Dial(IAX2/"identifier"/${EXTEN:4},40,rM(screen)) ; without r it seems to pass a second or two of audio first
exten => _9999XXXXXXXXXX,2,Hangup ; You can also substitute this with a Voicemail destination or other alternative destination

[macro-screen]
exten => s,1,Wait(1)
exten => s,n,Background(press-1-to-be-connected-to-the-caller) ; substitute a different playback file if you need to
exten => s,n,WaitExten(5) ; the value is the Wait time before we assume the call is not accepted
exten => 1,1,NoOp(Caller accepted) ; Do not set MACRO_RESULT to anything to connect the caller
exten => i,1,Set(MACRO_RESULT=CONTINUE)
exten => t,1,Set(MACRO_RESULT=CONTINUE)

[findme]
exten => s,1,NoOP(I'd rather the callers just hear ringing so they don't know they are calling something else)
exten => s,n,Dial(LOCAL/9999${findme1}&LOCAL/9999${findme2}&LOCAL/9999${findme3},40,m)


Combine Findme/Follow and AMD detection


I like very much the idea of sending a call to my cell. Letting my callers leave a message on my mobile phone company's mailbox, not so much. So I wrote this alternative, that will call my extension first. On no answer, will try my cell. Upon connection, a subroutine will be called: findmefollow-announce. I'm no fan of the "dial 1 to accept or 2 to reject" either, so I just had Festival tell me who is calling.

A word of advise with AMD, if you are indeed calling a cell or a phone in a noisy place, make sure you adjust the silence_threshold parameter accordingly (either in amd.conf or as a parameter of AMD()). In my case I changed it from 256 to 768, but it might take some playing around until you find the right setting for you.


[call-an-extension]
exten => s,1,Dial(SIP/12345,20,m)
exten => s,2,GotoIf($[${DIALSTATUS}" = "NOANSWER"]?3:4)
exten => s,3,Dial(SIP/5551212@voip-provider,30,$mU(findfollow-announce))
exten => s,4,Voicemail(12345@default)
exten => s,5,Hangup()

[findfollow-announce]
exten => s,1,Background(beep)
exten => s,2,AMD()
exten => s,3,Verbose(3,AMDSTATUS=${AMDSTATUS})
exten => s,4,Verbose(3,AMDCAUSE=${AMDCAUSE})
exten => s,5,GotoIf($["${AMDSTATUS}" = "HUMAN"]?6:8)
exten => s,6,Festival(You have a call from ${CALLERID(name)})
exten => s,7,Goto(9)
exten => s,8,Set(GOSUB_RESULT=CONTINUE)
exten => s,9,Return()


See also



Asterisk | Configuration | The Dialplan - extensions.conf | Dialplan Commands

This page has been viewed 57237 times since Tue 03 of Jan, 2006 (03:39 UTC)

Created by: lschweiss, Last modification: Thu 21 of Jul, 2011 (18:53 UTC) by fborcel
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+