How to make asterisk server automatically response

2019-01-29 07:15发布

问题:

My objective: I want to use softphone(3CX phone) register with asterisk server, and make call to the server and asterisk act

as a server to automatically response something, like play a song.

How i did: I installed asteriskNow using virtualbox, and registered the softphone by setting exntension for my SIP device

(extension 333). And i write a dialplan in etc/asterisk/extensions.conf. The dialplan is :

[incoming]
exten =>s,1,Answer()
exten =>s,n,Playback(dir-intro-oper)
exten =>s,n,Hangup()

I want any incoming call to server, the server will automatically answer, and play a pre-defined voice (dir-intro-oper.gsm )

then handup.

But I met the problem is:

I use softphone, and i dont know which number i should dial to the asterisk server. Should i set up a extension number for

asterisk server itself? If so, how to do that? By setting up SIP truck? Write the dialplan in sip.conf? or anything else?

Another questions: I read the asterisk related book"asterisk, the future telephony" which tells us to write dialplan in the extensions.conf

directly, but i found the extensions.conf in the server which alerts us do not modified the file directly, must use web-gui

to modify.So which way i should follow?

In this case, i do not use any other hardware phone. I am a novice on asterisk, please give me some hints and detail procedure.

回答1:

The "s" extension that you are using is a "special" that when Asterisk doesn't know what to do, it tries to use that.

If you really want any call to the box, either from a VoIP phone or an ITSP to get handled the same way, try this:

[incoming]
exten =>_X.,1,Answer()
same => n,Playback(dir-intro-oper)
same => n,Hangup()

... and make sure that in your SIP phone and SIP trunk definitions that you set:

context=incoming

That literally forces all calls into your context and then no matter what you dial, you always match the extension number.

More reading at https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching



回答2:

[incoming1]

exten => 333,1,Answer()
same  => n,Playback(File_name)
same  => n,Hangup()

Go to /etc/asterisk/extension_custom.conf and write your context like this:

and name the context as incoming1 or anything else cause incoming context already exists. I have named it as incoming1:

Now goto /etc/asterisk/sip_additional.conf and edit the context of extension you are going to register on the softphone.

Now register the softphone and you can dial the number 333 and everything will work properly.

![][3]