Play Some Greeting message at first when I dial any extension in Asterisk? - asterisk

I have 2 extensions 1101 and 1102, Both are different softphone.
Let's take a scenario, I dial 1102 from 1101 and 1102 ringing, but whenever 1102 answer the call 1101 heard some greeting voice/audio like "Hello How can I help you".
Please tell me what steps I should follow.
I will provide my extension.conf file code at last so you can more clear on that, also I didn't write that code so I am not familiar with that but please tell me I'll try my best.
[globals]
; General internal dialing options used in context Dial-Users.
; Only the timeout is defined here. See the Dial app documentation for
; additional options.
INTERNAL_DIAL_OPT=,30
[Hints]
; Allow dynamic hint creation for every extension.
exten = _11XX,hint,PJSIP/${EXTEN}
[Features]
; Extension to check user voicemail. We don't requre the user to enter
; their pincode.
exten = 8000,1,Verbose(1, "User ${CALLERID(num)} dialed the voicemail feature.")
same = n,VoiceMailMain(${CALLERID(num)}#example,s)
same = n,Hangup()
; Exten to dial the main IVR internally.
exten = 1100,1,Verbose(1, "User ${CALLERID(num)} dialed the IVR.")
same = n,Goto(Main-IVR,2565551100,1)
;Extension to enter a conference intended only for employees
exten = 6000,1,Verbose(1, "User ${CALLERID(num)} dialed the employee conference.")
same = n,Confbridge(employees)
same = n,Hangup()
;Extension to enter a conference intended for employees and customers
exten = 6500,1,Verbose(1, "User ${CALLERID(num)} dialed the employee/customer mixed conference.")
same = n,Confbridge(mixed)
same = n,Hangup()
[External-Features]
; Extension for users to remotely check voicemail. Here we require the caller to
; enter their mailbox and pincode.
exten = 2565551234,1,Verbose(1, "User ${CALLERID(num)} dialed into remote voicemail.")
same = n,VoiceMailMain(example)
same = n,Hangup()
; Extension to queue for sales.
; The queue has a 300 second timeout.
exten = 2565551200,1,Verbose(1, "User ${CALLERID(num)} dialed the sales queue.")
same = n,Answer()
same = n,Queue(sales,,,,300)
same = n,Goto(operator,1)
; Extension to queue for a customer advocate.
; The queue has a 1200 second timeout.
exten = 2565551250,1,Verbose(1, "User ${CALLERID(num)} dialed the customer advocate queue.")
same = n,Answer()
same = n,Queue(customer_advocate,,,,1200)
same = n,Goto(operator,1)
[Dialing-Errors]
; Handle any extensions dialed internally that don't otherwise exist.
; Comment out or remove this extension if you would rather have the calls
; ignored.
exten = _X.,1,Verbose(1, "User ${CALLERID(num)} dialed an invalid number.")
same = n,Playback(pbx-invalid)
same = n,Hangup()
[Internal-Setup]
; Here we capture internal calls to do anything we need to do before sending
; them onto all the possible internal locations. Such as disabling CDR on
; internal to internal calls.
exten = _X.,1,NoOp()
same = n,Set(CDR_PROP(disable)=1)
same = n,Goto(Internal-Main,${EXTEN},1)
; The Internal-Main context provides a way for internal callers to get access to most
; features and functions configured for them. External callers may be sent
; directly to some of the contexts you see included here, so the included
; contexts are not necessarily internal only.
[Internal-Main]
; The order of includes here is important for matching the right extensions.
include = Hints
include = Features
include = Dial-Users
include = Dialing-Errors
; Dial-Users handles calls to internal extensions.
; Calls coming into this context may be *external* or *internal* in origin.
[Dial-Users]
exten = _11XX,1,Verbose(1, "User ${CALLERID(num)} dialed ${EXTEN}.")
same = n,Set(SAC_DIALED_EXTEN=${EXTEN})
same = n,Gotoif($[${DEVICE_STATE(PJSIP/${EXTEN})} = BUSY]?dialed-BUSY,1:)
same = n,Dial(PJSIP/${EXTEN}${INTERNAL_DIAL_OPT})
same = n,Goto(dialed-${DIALSTATUS},1)
exten = dialed-NOANSWER,1,NoOp()
same = n,Voicemail(${SAC_DIALED_EXTEN}#example,u)
same = n,Hangup()
exten = dialed-BUSY,1,NoOp()
same = n,Voicemail(${SAC_DIALED_EXTEN}#example,b)
same = n,Hangup()
exten = dialed-CHANUNAVAIL,1,NoOp()
same = n,Playback(pbx-invalid)
same = n,Hangup()
exten = _dialed-.,1,Goto(dialed-NOANSWER,1)
exten = h,1,Hangup()
; Callers in the directory may dial 0 which will jump to the
; 'o' extension.
exten = o,1,Goto(1111)
; Outbound-Dial
;
; Before we dial, see if the extension matches our restricted number patterns.
; Note that this is a basic set of numbers which could incur a fee if dialed.
; The NANP includes many other numbers that you may want to block. If you feel
; it is necessary to block further number patterns you'll have to add them below
; or you may consider implementing a blacklist via methods beyond the scope of
; this example.
[Outbound-Dial]
exten = _011.,1,Hangup()
exten = _900NXXXXXX,1,Hangup()
exten = _1900NXXXXXX,1,Hangup()
exten = _976XXXX,1,Hangup()
exten = _NXX976XXXX,1,Hangup()
exten = _1NXX976XXXX,1,Hangup()
; Dial outbound through our SIP ITSP.
exten = _X.,1,Verbose(1, "Didn't match any restricted numbers, proceeding with outbound dial.")
same = n,Set(CALLERID(num)=256555${CALLERID(num)})
same = n,Dial(PJSIP/${EXTEN}#dcs-endpoint)
same = n,Hangup()
; Calls from internal endpoints will enter into one of the two following
; contexts based on their dialing privilege.
[Local]
include = Internal-Setup
exten = _NXXXXXX,1,Goto(Outbound-Dial,1256${EXTEN},1)
exten = _256NXXXXXX,1,Goto(Outbound-Dial,1${EXTEN},1)
exten = _1256NXXXXXX,1,Goto(Outbound-Dial,${EXTEN},1)
[Long-Distance]
include = Local
exten = _NXXNXXXXXX,1,Goto(Outbound-Dial,1${EXTEN},1)
exten = _1NXXNXXXXXX,1,Goto(Outbound-Dial,${EXTEN},1)
; The DID-Extensions context captures inbound calls from our ITSP that have a
; DID number where the last four digits matches an internal extension.
[DID-Extensions]
exten = _25655511XX,1,Verbose(1, "External caller dialed inbound to DID ${EXTEN})")
same = n,Goto(Dial-Users,${EXTEN:6},1)
; Our main IVR program for receiving inbound callers.
; The IVR script reads “Thank you for calling Super Awesome Company, Waldo’s
; premier provider of perfect products. If you know your party’s extension,
; you may dial it at any time. To establish a sales partnership, press one. To
; speak with a customer advocate, press two. For accounting and other
; receivables, press three. For a company directory, press four. For an
; operator, press zero.”
; demo-congrats is currently used as a placeholder.
[Main-IVR]
exten = 2565551100,1,Verbose(1, "New caller, ${CALLERID(num)} dialed into the IVR.")
same = n,Answer()
same = n(start),Background(basic-pbx-ivr-main)
same = n,WaitExten(10)
same = n,Background(basic-pbx-ivr-main)
same = n,Hangup()
exten = 0,1,Verbose(1, "Caller ${CALLERID(num)} dialed the operator.")
same = n,Goto(Dial-Users,1111,1)
exten = 1,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Sales queue.")
same = n,Goto(External-Features,2565551200,1)
exten = 2,1,Verbose(1, "Caller ${CALLERID(num)} dialed the Customer Experience queue.")
same = n,Goto(External-Features,2565551250,1)
exten = 3,1,Verbose(1, "Caller ${CALLERID(num)} dialed Accounting and Receivables.")
same = n,Goto(Dial-Users,1106,1)
exten = 4,1,Verbose(1, "Caller ${CALLERID(num)} dialed the directory.")
same = n,Directory(example,Dial-Users)
exten = i,1,Playback(option-is-invalid)
same = n,Goto(2565551100,start)
exten = t,1,Playback(are-you-still-there)
same = n,Goto(2565551100,start)
; Calls from our ITSP SIP account arrive in DCS-Incoming. We should be careful
; to route calls very explicitly so as to avoid any security issues, such as
; accidentally giving outbound dial access to inbound callers.
;
; Each context includes extension pattern matching to match the inbound DID
; dialed appropriately.
[DCS-Incoming]
include = Main-IVR
include = DID-Extensions
include = External-Features
I know it's huge and there are more than just simple dial and answer the call in code.
Please tell me if anything did not clear.

There are no easy way do that.
You can use this dial option, but it will broke cdr
G( context^exten^priority ) - If the call is answered, transfer the calling party to the specified priority and the called party to the specified priority plus one.
context
exten
priority

Related

How to call an another phone after hangup the first?

I would like to call a phone, hangup and call an another phone from the server.
Like this :
Server->Phone A->Hangup->Server->phone B
This is what I already tried :
[appel]
exten => a,1,Answer
[do something]
exten => 2,1,Goto(pasCharge)
[pasCharge]
exten => [do something]
exten => ce,2,Dial(SIP/vincent)
exten => [doSomething]
exten => ce,3,Hangup
I have the first call (appel) but not the second (centre). It just hangup after the first.
Could you help me please ?
If you want dialplan be able continue after hangup of first call, you shoudl add g option to dial param
pro-sip.net> core show application Dial
-= Info about application 'Dial' =-
.....
[Syntax]
Dial(Technology/Resource[&Technology2/Resource2[&...]][,timeout[,options[,URL]]])
....
g: Proceed with dialplan execution at the next priority in the current
extension if the destination channel hangs up.
To build on what #arheops was saying, adding the lowercase g in the Dial() command instructs Asterisk that when the called party hangs up, continue to execute commands in the current context at the next priority.
So you could do something like this:
[pasCharge]
exten => ce,2,Dial(SIP/vincent,g)
exten => ce,3,Dial(SIP/Vbourdon,g)
exten => ce,4,[doSomething]
This would dial vincent then Vbourdon, and your doSomething could be a Goto, etc, anything you like.

Playback an audio file to a specific channel in asterisk dialplan

I need to make a voice translation service on active calls like skype, for that purpose I need to record voice from caller and whisper the translated voice to callee and vise-versa
I need to add to the dialplan lines to playback audio to the other channel with lower voice but current playback app doesn't have this option
any solution for that?
this is my code below
[macro-speech]
;;Speech recognition demo:
;exten => s,1,Answer()
exten => s,1,agi(googletts.agi,"Say something in English, when done press the pound key.",en)
exten => s,n(record),agi(speech-recog.agi,en-us)
exten => s,n,Verbose(1,Script returned: ${confidence} , ${utterance},en-us)
;Check the probability of a successful recognition:
exten => s,n(success),GotoIf($["${confidence}" > "0.6"]?playback:retry)
;Playback the text:
exten => s,n(playback),agi(googletts.agi,"The text you just said was...",en)
exten => s,n,agi(googletts.agi,"${utterance}",en)
;------------- Translate to different languages
;Translate a text string from english to german:
exten => s,n,agi(googletranslate.agi,"${utterance}",de)
exten => s,n,agi(googletts.agi,"${gtranslation}",de)
;------------------------------------------------
exten => s,n,goto(record)
;Retry in case speech recognition wasn't successful:
exten => s,n(retry),agi(googletts.agi,"Can you please repeat more clearly?",en)
exten => s,n,goto(record)
exten => s,n(fail),agi(googletts.agi,"Failed to get speech data.",en)
exten => s,n(end),Hangup()
freepbx11*CLI> core show function VOLUME
-= Info about function 'VOLUME' =-
[Synopsis]
Set the TX or RX volume of a channel.
[Description]
The VOLUME function can be used to increase or decrease the 'tx' or 'rx' gain
of any channel.
For example:
Set(VOLUME(TX)=3)
Set(VOLUME(RX)=2)
Set(VOLUME(TX,p)=3)
Set(VOLUME(RX,p)=3)
[Syntax]
VOLUME(direction[,options])
[Arguments]
direction
Must be 'TX' or 'RX'.
options
p: Enable DTMF volume control
[See Also]
Not available
freepbx11*CLI>

what should be entries in extensions /& sip /& queue conf in Asterisk for call forwarding by default?

I am trying to learn how i can add call forwarding facility for few phones by default in Asterisk via conf files entries. My Asterisk version 1.6.2.6
I read http://www.voip-info.org/wiki/view/Asterisk+call+forwarding
In my scenario i have 3 entries like 10,11,12 which always answer the calls.
But i am trying to do call forwarding ie if 10 busy then call should go to 11, if 11 busy then call goes to 12,if 12 then call end with recorded tape that 'all are busy'.
For that i read above link data, as per my knowledge i have to change my dial plan. but in examples all showing first i should click # key & save it. but i need by default call forwarding. As if phone 50 calls 10 then if 10 not busy then it goes to 10 only. But if 51 calls 10 then it goes to 11 because 10 busy with 50.
I am giving example of phone 10 entries in Asterisk conf files same for other also.
My extension.conf entries:
exten => 0010,2,Queue(0010)
exten => 0110,1,Dial(SIP/0110)
exten => 0210,1,Dial(SIP/0210)
My sip.conf entries:
[0010]
username = 0010
secret = 0010
type = friend
insecure = port,invite
host = dynamic
context = users
[0110]
username = 0110
secret = 0110
type = friend
insecure = port,invite
host = dynamic
context = users
[0210]
username = 0210
secret = 0210
type = friend
insecure = port,invite
host = dynamic
context = users
My queues.conf entries:-
[0010]
member => SIP/0010
Where & what i should add in above entries so call forwarding done in my Asterisk?
Please check this book
http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html/asterisk-book.html#asterisk-ACD
Or this book
http://cdn.oreilly.com/books/9780596510480.pdf
Both have full description for your case.
I'm using Asterisk 10,centos 6. and I'V done changes in conf file as below for call forwarding
"extension.conf"
exten => 0010,1,Wait(0.05)
exten => 0010,2,Queue(0010)
exten => 0010,n,Dial(SIP/0011,15)
exten => 0010,n,Dial(SIP/0012,15)
exten => 0110,1,Dial(SIP/0110)
exten => 0210,1,Dial(SIP/0210)
"queues.conf"
;----------------------QUEUE TIMING OPTIONS------------------------------------
timeout = 15
retry = 5
;timeoutpriority = app|conf
timeoutpriority = conf
[0010]
member => SIP/0010
[0011]
member => SIP/0011
[0012]
member => SIP/0012
Please suggest wheather i'm right if not then please suggest some answer based on given .conf files

Get extensions list in Asterisk with AMI

I'm running Asterisk 11.4.0 and I've got access to it with AMI. How can I get list of all extensions (not peers or users)?
For example, I've got dialplan like this:
exten = _XXXX,1,Verbose(Start recording!)
exten = _XXXX,2,NoOp()
exten = _XXXX,3,Set(SCREEN_FILE=${STRFTIME(${EPOCH},,%d.%m.%Y-%H:%M:%S)}_${CALLERID(num)}>${EXTEN}.gsm)
exten = _XXXX,4,MixMonitor(${SCREEN_FILE},b)
exten = _XXXX,5,Dial(SIP/${EXTEN})
exten = _XXXX,6,StopMonitor()
exten = _XXXX,7,Hangup()
exten = _49000030[0-9a-zA-Z.#_/-].,1,Goto(test1,${EXTEN},1)
exten = _49000033[0-9a-zA-Z.#_/-].,1,Goto(test2,${EXTEN},1)
So, my extensions are _XXXX, 49000030[0-9a-zA-Z.#/-]. and 49000033[0-9a-zA-Z.#/-].
Hate answering my own questions, but...
For this purpose one can use AMI command like this:
Action: 'GetConfig',
Filename: 'extensions.conf',
Category: 'default'
In the response, you will get object containing each line of "default" context as it's field. All the extensions can be easily parsed from it.

I have server Asterisk I want display sip channel in mixmonitor

I have 1 server Asterisk I want save sound file in folder & I can save to folder but I can't Rename file name I want when one call coming into server when called wit sip Chanel number sip saved to name file sound I want type code into context
[voicemenu-custom-1]
include = default
exten = s,1,NoOp(VM_Main)
exten = s,2,Answer()
exten = s,3,Set(CALLFILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID}-${CALLERID(num)})
exten = s,4,Set(CALLFILENAMES=${REPLACE(CALLFILENAME,*)})
exten = s,5,MixMonitor(${CALLFILENAMES}.wav,bW(2))
exten = s,6,Set(CDR(userfield)=audio:${CALLFILENAMES}.wav)
exten = s,7,AGI(agi://192.168.27.85/customivr)
exten = s,8,GotoIf($[${AGISTATUS} != "SUCCESS"]?ringgroup:hangup)
exten = s,9(ringgroup),Goto(ringroups-custom-1,s,1)
exten = s,10,System(/var/lib/asterisk/scripts/checkrcm.sh ${UNIQUEID}
${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)} ${CALLERID(num)})
exten = s,11(hangup),StopMixMonitor()
exten = s,12,Hangup()
when call received you have DAHDI channel but you can't define sip channel until call answered by one user. lool :-> you can add dahdhi channel to your file name but you can't save sip channel. if you want this you have to rename file in hangup event

Resources