Question

Below is an IVR that has been written in lua for freeswitch. I have not copied the whole IVR, just some portion from the start of the file.

 session:set_tts_parms("flite", "kar");
    session:speak("Welcome to the VoIP World!");
    while(session:ready() == true) do
            session:speak("to go to the next level, press 1");
            session:speak("to hear my voice some more, press 2");
            session:speak("to go to the default IVR demo, press 5");
            session:speak("to exit, press 9");
            digits = session:getDigits(1, "", 3000);
            freeswitch.consoleLog("info", "Got dtmf: ".. digits .."\n");



if (digits == "1") then
                --next level stuff
                session:speak("you selected 1");
                while(session:ready() == true) do
                        session:speak("to hear me speak, press 1");
                        session:speak("to go back to the previous menu, press 2");
                        session:speak("to exit, press 9");
                    digits = session:getDigits(1, "", 3000);
                    freeswitch.consoleLog("info", "Got dtmf, level2: ".. digits .."\n");
                    if (digits == "1") then
                            session:speak("Some people will tell you that life is good");
                    elseif (digits == "2") then
                            break;
                    elseif (digits == "9") then
                            session:hangup();
                    end
            end
    elseif (digits == "2") then
            session:speak("What a Ride!");

I have also written an IVR (just an example not necessarily the same) for asterisk server using dial plan,that is given below.

[incoming]
exten => 123,1,Answer()
 same => n(menuprompt),Background(main-menu)

exten => 1,1,Playback(digits/1)
 same => n,Goto(menuprompt)

exten => 2,1,Playback(digits/2)
 same => n,Goto(menuprompt)

exten => 9,1,Hangup()

[main-menu]
exten => n(menuprompt),Background(main-menu)

exten => 3,1,Playback(digits/3)
 same => n,Goto(menuprompt)

exten => 4,1,Playback(digits/4)
 same => n,Goto(menuprompt)

exten => 9,1,Hangup()

Now my question to emulate the lua code above in functionality do I need some glue code or is the IVR above enough.If I program an IVR in one SIP server and dial from a sip phone to that sip server will it play the menu. I am trying to understanding the architecture and seem to be missing some portions.Any help is appreciated.

Was it helpful?

Solution

I don't see a reason why you would need two IVR servers with the same functionality. In your Asterisk dialplan, you can make a rule to forward the call to FreeSWITCH, and then your Asterisk users would be connected there.

OTHER TIPS

You're close, but not quite.

Think of contexts as physical boxes. You can't go through the walls in the box. So, "labels" (like you n(menuprompt)) and extensions only apply to what is in that one particular box / context.

In [incoming] context, your calls to "Goto(menuprompt)" will refer to the "(menuprompt)" label in the [incoming] context.

In the [main-menu] context, your calls to "Goto(menuprompt)" will refer to the "(menuprompt)" label in the [main-menu] context.

The "n" priority is a construct that means "one more than the previous priority for this extension in this context".

So the biggest issue with your dialplan is that you have a new context [main-menu] but no initial extension number. So your

exten => n(menuprompt),Background(main-menu)

... is "dead" code. It doesn't do anything because there is no extension associated with it.

So, to fix your code, you'll need to do something like

exten => 1,1,Playback(digits/1)
 same => n,Goto(main-menu,3,1)

... to be able to jump from [incoming] to [main-menu]. To jump back, you'll do the inverse.

Further reading: https://wiki.asterisk.org/wiki/display/AST/Contexts,+Extensions,+and+Priorities

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top