created dialog manager

Aug 8, 2013 at 5:24 PM
One days effort .. allows for the creation of dialogs with prompt/timeout/input dispatching/goto-dialog/gosub-dialog etc. Works really well. Below is a stupid 2 dialog example of an IVR. Plan to add voicereco support and some more refinements to allow for the creation of useful IVRs. Will submit code for consideration when done ...
   class DialogIVR : Asterisk.NET.AGIDialogApplication
    {
        protected override void Initialize(AGIRequest request, AGIChannel channel)
        {
            globalData.Add("escapeKeys", "0123456789*#");

            AGISimpleSingleDTMFInputDialog d1 = new AGISimpleSingleDTMFInputDialog("d1");
            d1.setInitialPrompt("main-menu");
            d1.setBadInputPrompt("wrong-try-again-smarty");
            d1.setInputTimeoutAndTimeoutPrompt(5000, "please-try,press-1,press-2,press-3");
            d1.setExitPrompt("one-moment-please");
            d1.addResponse('1', (char c) => { StreamFile("press-1"); return false; });
            d1.addResponse('2', (char c) => { StreamFile("press-2"); return false; });
            d1.addResponse('3', "d2");

            AGISimpleSingleDTMFInputDialog d2 = new AGISimpleSingleDTMFInputDialog("d2");
            d2.setInitialPrompt("weasels-eaten-phonesys");
            d2.setBadInputPrompt("wrong-try-again-smarty");
            d2.setInputTimeoutAndTimeoutPrompt(5000, "please-try,press-1,press-2,press-3");
            d2.setExitPrompt("one-moment-please");
            d2.addResponse('1', (char c) => { Hangup(); return false; });
            d2.addResponse('2', (char c) => { StreamFile("press-2"); PlayMusicOnHold();  return false; });
            d2.addResponse('3', "d1");

            addDialog(d1, true);
            addDialog(d2);

            base.Initialize(request, channel);
        }
        protected override void terminate()
        {
            base.terminate();
        } 
    }
Aug 8, 2013 at 10:09 PM
Looks interesting!