public static State Build(string Id, VoiceModel vm)
        {
            State vState = new State(Id);

            vState.DataModel = vm;
            return(vState);
        }
        public virtual string Tropo(Result result)
        {
            _log.Debug("Recieved Tropo request: ", result);
            string vEvent;
            string vData;
            string vErrMsg;

            TropoUtilities.TropoResultToEventAndData(result, out vEvent, out vData, out vErrMsg);
            CallFlow.ICallFlow callFlow = GetCallFlow(result.sessionId);
            callFlow.FireEvent(vEvent, vData);

            VoiceModel doc = callFlow.CurrState.DataModel;

            if (isJson(callFlow.CurrState.jsonArgs))
            {
                doc.json = callFlow.CurrState.jsonArgs;
            }
            if (doc.ViewName == "Call")
            {
                doc.nextUri = doc.nextUri + "/Tropo";
            }
            else
            {
                doc.nextUri = TropoUri;
            }
            SetCallFlow(callFlow, result.sessionId);
            string recordingUri = TropoRecordingUri + "?vm_session_id=" + result.sessionId;
            string json         = TropoUtilities.ConvertVoiceModelToWebApi(doc, recordingUri);

            _log.Debug("Sending Tropo response:[" + json + "]");
            return(json);
        }
        protected virtual ActionResult VoiceView(string id, string vEvent, string json, string sessionId)
        {
            if (string.IsNullOrEmpty(sessionId))
            {
                throw new Exception("Session ID cannot be empty or null."); // TODO: Return an error view indicating the issue.
            }
            CallFlow.CallFlow callFlow = GetCallFlow(sessionId);
            callFlow["Channel"] = "VOICE";

            callFlow.SessionId = sessionId;
            callFlow.FireEvent(vEvent, json);

            VoiceModel doc = callFlow.CurrState.DataModel;

            if (isJson(callFlow.CurrState.jsonArgs))
            {
                doc.json = callFlow.CurrState.jsonArgs;
            }
            if (doc.ViewName == "Call")
            {
                doc.nextUri = doc.nextUri + "/StateMachine";
            }
            else if (doc.ViewName == "Record")
            {
                doc.nextUri = VxmlRecordingUri;
            }
            else
            {
                doc.nextUri = VxmlUri;
            }

            SetCallFlow(callFlow, sessionId);

            return(View(doc.ViewName, doc));
        }
Exemple #4
0
 public Say(VoiceModel doc, string id, Prompt prompt)
     : base(doc)
 {
     this.viewName = "Output";
     this.id       = id;
     this.prompts  = new List <Prompt>();
     this.prompts.Add(prompt);
 }
Exemple #5
0
 public Say(VoiceModel doc, string id, string altText)
     : base(doc)
 {
     this.viewName = "Output";
     this.id       = id;
     this.prompts  = new List <Prompt>();
     this.prompts.Add(new Prompt(altText));
 }
Exemple #6
0
 public Ask(VoiceModel doc)
     : base(doc)
 {
     this.viewName  = "Input";
     initialPrompt  = new List <Prompt>();
     noinputPrompts = new List <Prompt>();
     nomatchPrompts = new List <Prompt>();
 }
Exemple #7
0
 public VoiceModel(VoiceModel doc)
 {
     this.id         = doc.id;
     this.AppName    = doc.AppName;
     this.properties = doc.properties;
     this.viewName   = doc.viewName;
     this.json       = doc.json;
     this.nextUri    = doc.nextUri;
     this.AllowSettingControllerName = true;
 }
Exemple #8
0
 public Ask(VoiceModel doc, string id, string textPrompt, Grammar grammar)
     : base(doc)
 {
     this.viewName  = "Input";
     initialPrompt  = new List <Prompt>();
     noinputPrompts = new List <Prompt>();
     nomatchPrompts = new List <Prompt>();
     this.id        = id;
     this.initialPrompt.Add(new Prompt(textPrompt));
     this.grammar = grammar;
 }
Exemple #9
0
        public Record(VoiceModel doc)
            : base(doc)
        {
            this.confirm             = true;
            this.confirmationPrompts = new List <Prompt>();
            Prompt cprompt = new Prompt("I heard you say ");

            cprompt.bargein = false;
            cprompt.audios.Add(new TtsVariable("CallersMessage"));
            cprompt.audios.Add(new Silence(1000));
            cprompt.audios.Add(new TtsMessage("To save this message say yes. To discard it say no."));
            this.confirmationPrompts.Add(cprompt);
            this.viewName = "Record";
            this.prompts  = new List <Prompt>();
            this.maxtime  = 60;
        }
        public virtual string StartTropo(string id, Session session)
        {
            _log.Debug("Recieved Tropo start request: ", session);
            string vEvent = "";
            string vData  = "";

            CallFlow.CallFlow callFlow = BuildCallFlow();
            if (string.IsNullOrEmpty(id))
            {
                id = "unknown";
            }
            callFlow["AppId"]       = id;
            callFlow["ANI"]         = session.from.id;
            callFlow["Channel"]     = session.from.channel;
            callFlow["InitialText"] = session.initialText;

            callFlow.FireEvent(vEvent, vData);

            VoiceModel doc = callFlow.CurrState.DataModel;

            if (isJson(callFlow.CurrState.jsonArgs))
            {
                doc.json = callFlow.CurrState.jsonArgs;
            }
            if (doc.ViewName == "Call")
            {
                doc.nextUri = doc.nextUri + "/Tropo";
            }
            else
            {
                doc.nextUri = TropoUri;
            }
            SetCallFlow(callFlow, session.id);
            string recordingUri = TropoRecordingUri + "?vm_session_id=" + session.id;
            string json         = TropoUtilities.ConvertVoiceModelToWebApi(doc, recordingUri);

            _log.Debug("Sending Tropo response:[" + json + "]");
            return(json);
        }
Exemple #11
0
 public void Add(VoiceModel doc)
 {
     _views.Add(doc.id, doc);
 }
Exemple #12
0
 public Say(VoiceModel doc)
     : base(doc)
 {
     this.viewName = "Output";
     this.prompts  = new List <Prompt>();
 }
Exemple #13
0
 public VoiceState(string Id, VoiceModel vm)
     : base(Id)
 {
     this.DataModel = vm;
 }
Exemple #14
0
 public VoiceState(string Id, string target, VoiceModel vm)
     : base(Id, target)
 {
     this.DataModel = vm;
 }