Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Ekim
Ekim

Posted on

     

Basic IVR with Asterisk

Weekly sharing

Hi everyone, I am Ekim, a fresh Bootcamp graduate and an IT helper (I don't dare to call myself a programmer yet). Every Friday, I will share some of the work that I've done over the last week in a bid to get feedbacks from you guys and record my journey to become a programmer.

Previously

Asterisk Manager with JavaScript

Introduction

Today, I would like to share how we could make a simple interactive voice response (IVR). I know you might have had some horrible experiences with that, but it would be a weird but fun experience when you hear your voice on the phone talking to you.

What is Interactive Voice Response (IVR) menu?

  • An IVR menu is a list of options that are presented to aninbound caller which prompts them tomake a selection, thus qualifying the call anddirecting it to the mostappropriate contact.

Recording our own audio track through Asterisk for IVR

  • If you have read my previous posts, you would know that the codecs that telephony supports are limited.

  • Even if you have recorded a very good quality audio track, you still need to convert it into the format that our phones support.

  • To save time, I am not going to go through theffmpeg part again. Instead, I am going to record all the IVR audio track through theRecord dialplan application.

  • In pjsip.conf

    [transport-udp-nat]type =transportprotocol =udpbind =0.0.0.0    [calling](!)type=endpointcontext=interactionallow = !all,ulaw,alawdirect_media=notrust_id_outbound=yesrtp_symmetric=yesforce_rport=yesrewrite_contact=yesdevice_state_busy_at=1dtmf_mode=rfc4733    [auth-userpass](!)type =authauth_type =userpass         [aor-single-reg](!)type =aormax_contacts =1             [7000](calling)auth=7000aors=7000callerid =7000 <7000>       [7000](auth-userpass)password =7000username =7000    [7000](aor-single-reg)mailboxes =7000@main    [7100](calling)auth=7100aors=7100callerid =7100 <7100>    [7100](auth-userpass)password =7100username =7100    [7100](aor-single-reg)mailboxes =7100@main
Enter fullscreen modeExit fullscreen mode
  • In extensions.conf
[interaction]exten = *555,1,NoOp(recording)same =n,Answersame =n,Record(record/greeting.wav)same =n,Playback(vm-received)same =n,Playback(en/digits/1)same =n,Record(record/press1.wav)same =n,Playback(vm-received)same =n,Playback(en/digits/2)same =n,Record(record/press2.wav)same =n,Playback(vm-received)same =n,Playback(en/digits/3)same =n,Playback(vm-last)same =n,Record(record/wrong-key.wav)same =n,Playback(vm-received)same =n,Playback(en/digits/4)same =n,Hangup;exten =_7X00,1,NoOp(Callfor ${EXTEN})    ;same =n,Dial(PJSIP/${EXTEN})      ;same =n,Hangupexten =8888,1,NoOp(CallIVR)same =n,Goto(ivr,s,1)[ivr]exten =s,1,NoOp(YouareinIVRnow)same =n,Answer                     ;hereisthestartoftheSIPprotocolsame =n(play),Playback(record/greeting)same =n,WaitExten(10)              ;wait10secondsforthecallertopresskeyexten =1,1,NoOp(Pressed1)same =n,Playback(record/press1)same =n,Goto(s,play)               ;gobackto'n(play),Playback(record/greeting)'exten =2,1,NoOp(Pressed2)same =n,Playback(record/press2)same =n,Goto(s,play)exten =i,1,NoOp(unknownkey)       ;handleinvalidkeys -->whenkeysotherthan1and2arepressedsame =n,Playback(record/wrong-key)same =n,Goto(s,play)exten =t,1,NoOp(Waitedtoolongforexten)     ;handleWaitExtentimeoutsame =n,Goto(s,play)
Enter fullscreen modeExit fullscreen mode

Implementation

  • First of all, let's record all the necessary navigation menu tracks.
  • I have set in the dialplan that when we call*555, we will start recording each audio file one by one.- When you hear the first 'beep' sound, it is for the recording of the greeting. - For example, "thanks for calling, English, press 1; Deutsch, press 2". - When you finish each recording, remember to press#to save it.
  • If successful, you will hear the number of recording received.
    • If you finished one recording, you will hear "received 1"
  • When you hear "last", that means you are going to record the last audio.
  • Here is the sequence of the recording sections

    1. greeting
      1. the navigation after pressing 1
      2. the navigation after pressing 2
      3. the navigation when wrong key is pressed
  • To go into the IVR, dial8888 and it will start the IVR menu.

Conclusion

Now, you have just made yourself an IVR menu. If you follow tight, you would realize that the whole IVR is a loop. You could feel free to add theHangup dialplan application wherever you like. One thing I would like to stress here is that this IVR structure is a very basic one as things are repetitive and could be refactorized in another way. A more advanced one might be introduced some time later (I hope ... ) with the use of database and AGI (Asterisk Gateway Interface). That's all for today. See you next time.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

More fromEkim

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp