
Good day habrazhiteli.
I would like to share the experience of deploying voice trees (IVR) using Asterisk.
For this we need:
- Machine with Asterisk installed
- A phone number that was entered into Asterisk via SIP / H.323 from an IP telephony provider, or via an analogue E1 line / digital stream via Digium cards
Below I will describe how to create a simple voice tree. The main thing that needs to be repelled is the structure of the tree.
A typical tree looks like this:
- Hello, you called% companyname%
- To connect with department 1 press 1
- To connect with department 2 press 2
- To send a fax press 9
- If you know the subscriber’s internal number, dial it in tone mode or wait for the secretary’s answer
We can also offer the caller to connect the necessary specialist from the department that he chose above. So, for example, if he chose the first department, then we can reproduce the following information to him:
- You are in department menu 1
- To connect with a specialist in% X% press 5
- To connect with a specialist in% Y% press 6
- To return to the previous menu, press 0.
')
Let's start the implementation! Assume that we have the number 8-495-1234567 on which we will “grow” our tree. All incoming and outgoing routing in Asterisk, as a rule, is located in the
extensions.conf file, which is located in the root folder of the asterisk - / etc / asterisk. I believe that it is more convenient to create Ivr-trees in separate files, so we will create the
company.tree file in the Asterisk root folder and enter one line for now:
[company_tree]
On this, we leave editing the
company.tree file and move on to the
extensions.conf file - at the beginning of this file we add the following:
#include "company.tree"
To load the newly created file into the Asterisk general routing plan. Now let's move the main context for incoming calls (for all, it can be called differently - general, from_pstn, from_e1, or how you like it more) and add the following line to it:
exten => 84951234567,1,Goto(company_tree,s,1)
When an incoming call to the number 84951234567 Asterisk translates us into the context of the company_tree on the first line "s", which is in the file company.tree, which we safely loaded into the general routing plan above. It sounds a bit confusing, but this nesting will help us avoid incidents of incorrect routing due to the intersection of several contexts in the
extensions.conf file.
At this stage, go to the file company.tree and actually begin to “build” the Ivr-tree - add the following lines to it:
exten => s,1,Answer()
#
exten => s,2,Background(/home/ulaw/IVR-zapis)
# *
exten => s,3,WaitExten(7)
# , 7
exten => 1,1,Goto(otdel1,s,1)
# 1
exten => 2,1,Goto(otdel2,s,1)
#
exten => 9,1,Set(FAXFILE=/tmp/fax/${STRFTIME(${EPOCH},,%Y%m%d_%H_%M_%S)}-from-${CALLERID(num)}) # , -
exten => 9,2,ReceiveFax(${FAXFILE}.tif)
#
exten => 9,3,System(sendEmail -f fax@company.com -t you@company.com -u " ." -m " ${CALLERID(num)} ${STRFTIME(${EPOCH},,%H:%M:%S)}. ." -a ${FAXFILE}.tif -o message-charset=UTF-8)
#
exten => _XXX,1,Dial(SIP/${EXTEN}@YourAsterisk)
# , :)
exten => t,1,Dial(SIP/ @YourAsterisk)
# , 7
exten => i,1,Dial(SIP/ @YourAsterisk)
# ,
[otdel1]
# -
exten => s,1, Background(/home/wav/otdel1)
# - " 1"
exten => s,2,Waitexten(7)
#
exten => 1,1,Dial(SIP/ @YourAsterisk)
# %X%
exten => 2,1,Dial(SIP/ @YourAsterisk)
# %Y%
exten => t,1,Dial(SIP/ @YourAsterisk)
# -
exten => 0,1,Goto(company_tree,s,1)
#
On this tree is ready. It remains only to update the routing of the asterisk - for this it is necessary to perform in the terminal:
asterisk -r
dialplan reload
* Asterisk files with * .ulaw extension are used as audio files. It must be remembered that when composing voice trees, in those places where the paths to the audio are indicated, the file extension is not indicated - for example,
“Background (/ home / IVR / zapis1)” . To work with this format, I used the software - CoolEdit and Adobe Audition, if anyone knows more sound editors with support and conversion ulaw, write, I will be grateful.