Question : Asterisk: Detect incoming call

In asterisk/elastix/freepbx

How do you
1- detect an incoming call
2- read the caller id
3- do something...(perform function)

?

Answer : Asterisk: Detect incoming call

Hello Robert,

There are several case scenarios for an incoming call :

* If you have an analog line connected to an analog card in your server: the card will be configured so that any incoming call is sent to a particular context in the dialplan. Then all incoming calls will be sent to extension s, priority 1. For example:

-> Configuration:
FXO analog card port 1 : context = analog1

-> Dialplan:
[analog1]
exten => s,1,Answer()
exten => s,n,Playback(thank-you-for-calling)
exten => s,n,Hangup()

* If you have an ISDN formatted digital T1, such as PRI, you will simply define a context for your PRI. All incoming calls will be sent to that context, to the extension matching the DID sent through the PRI, at priority 1 (i'd recommend to ask your carrier to send you the whole 10 digits, so it makes it easy to read from the dialplan). For example:

-> Configuration:
T1 span: context = t1

-> Dialplan:
[t1]
exten => 2035551122,1,Answer()
exten => 2035551122,n,Playback(thank-you-for-calling)
exten => 2035551122,n,Hangup()


exten => 2035551155,1,Answer()
exten => 2035551155,n,Playback(thank-you-for-calling)
exten => 2035551155,n,Hangup()


* If you have a SIP phone connected to your asterisk server, this SIP phone will have a context defined. When a number is dialled on the sip phone, Asterisk will look for an extension matching this number in the context of the sip phone. For example:

-> Configuration:
SIP phone: context = sipphone

-> Dialplan:
[sipphone]
exten => 100,1,Answer()
exten => 100,n,Playback(thank-you-for-calling)
exten => 100,n,Hangup()


exten => 102,1,Answer()
exten => 102,n,Playback(thank-you-for-calling)
exten => 102,n,Hangup()


This is how it works in a nutshell, don't hesitate to ask more questions if you have any.
Random Solutions  
 
programming4us programming4us