Exemple #1
0
        public override void GetNewTask()
        {
            if (stats.MoneyAmount <= 5)
            {
                var bank = FindObjectOfType <Building_Normal_Service_Bank>();
                if (bank == null)
                {
                    return;
                }

                CurrentAction = new BuyFromStore(this, bank);
                return;
            }


            var rand = Random.Range(1, 4);

            if (rand == 1)
            {
                CurrentAction = new TalkAction(this, WorldObjects.GetPersonTarget(this), Random.Range(5f, 15f));
            }
            if (rand == 2)
            {
                CurrentAction = new IdleMovement(this, Random.Range(5f, 15f));
            }
            if (rand == 3)
            {
                var store = FindObjectOfType <Building_Normal_Service_Store>();
                if (store == null)
                {
                    return;
                }
                CurrentAction = new BuyFromStore(this, store);
            }
        }
Exemple #2
0
        public IActionResult Answer()
        {
            var host = Request.Host.ToString();
            //Uncomment the next line if using ngrok with --host-header option
            //host = Request.Headers["X-Original-Host"];
            var sitebase       = $"{Request.Scheme}://{host}";
            var outGoingAction = new TalkAction()
            {
                Text = "Please leave a message after the tone, then press #. We will get back to you as soon as we can"
            };
            var recordAction = new RecordAction()
            {
                EventUrl     = new string[] { $"{sitebase}/recordmessage/webhooks/recording" },
                EventMethod  = "POST",
                EndOnSilence = "3",
                EndOnKey     = "#",
                BeepStart    = "true"
            };
            var thankYouAction = new TalkAction {
                Text = "Thank you for your message. Goodbye"
            };
            var ncco = new Ncco(outGoingAction, recordAction, thankYouAction);

            return(Ok(ncco.ToString()));
        }
Exemple #3
0
        public IActionResult Answer()
        {
            var TO_NUMBER     = Environment.GetEnvironmentVariable("TO_NUMBER") ?? "TO_NUMBER";
            var VONAGE_NUMBER = Environment.GetEnvironmentVariable("VONAGE_NUMBER") ?? "VONAGE_NUMBER";
            var host          = Request.Host.ToString();
            //Uncomment the next line if using ngrok with --host-header option
            //host = Request.Headers["X-Original-Host"];

            var eventUrl   = $"{Request.Scheme}://{host}/SplitAudio/webhooks/recording";
            var talkAction = new TalkAction {
                Text = "recording call", BargeIn = "false"
            };
            var recordAction = new RecordAction()
            {
                EventUrl    = new string[] { eventUrl },
                EventMethod = "POST",
                Channels    = 2,
                Split       = "conversation"
            };

            var connectAction = new ConnectAction()
            {
                From     = VONAGE_NUMBER,
                Endpoint = new[] { new PhoneEndpoint {
                                       Number = TO_NUMBER
                                   } },
            };

            var ncco = new Ncco(talkAction, recordAction, connectAction);

            return(Ok(ncco.ToString()));
        }
Exemple #4
0
        public string AnswerForTrackInProgressNCCO()
        {
            var talkAction = new TalkAction()
            {
                Text = "This is a text to speech call from Nexmo"
            };

            var payload = new Foo()
            {
                Bar = "Bar"
            };

            var nofityAction = new NotifyAction()
            {
                EventUrl = new[] { $"{SITE_BASE}/voice/Notify" },
                Payload  = payload
            };

            var talkAction2 = new TalkAction()
            {
                Text = "You'll never hear this talk action because the notification handler will return an NCCO"
            };

            var ncco = new Ncco(talkAction, nofityAction, talkAction2);

            return(ncco.ToString());
        }
        public void Execute()
        {
            var VONAGE_APPLICATION_ID   = Environment.GetEnvironmentVariable("VONAGE_APPLICATION_ID") ?? "VONAGE_APPLICATION_ID";
            var VONAGE_PRIVATE_KEY_PATH = Environment.GetEnvironmentVariable("VONAGE_PRIVATE_KEY_PATH") ?? "VONAGE_PRIVATE_KEY_PATH";
            var UUID = Environment.GetEnvironmentVariable("UUID") ?? "UUID";

            var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH);
            var client      = new VonageClient(credentials);

            var talkAction = new TalkAction()
            {
                Text = "This is a transfer action using an inline NCCO"
            };
            var ncco            = new Ncco(talkAction);
            var callEditCommand = new CallEditCommand()
            {
                Action      = CallEditCommand.ActionType.transfer,
                Destination = new Destination()
                {
                    Ncco = ncco
                }
            };

            var response = client.VoiceClient.UpdateCall(UUID, callEditCommand);

            Console.WriteLine($"Call transfer success: {response}");
        }
Exemple #6
0
        public void should_call_with_NCCO()
        {
            var talkAction = new TalkAction()
            {
                Text = "This is a text to speech call from Nexmo"
            };
            var ncco    = new Ncco(talkAction);
            var results = Call.Do(new Call.CallCommand
            {
                to = new[]
                {
                    new Call.Endpoint
                    {
                        Type   = "phone",
                        number = Configuration.Instance.Settings["test_number"]
                    }
                },
                from = new Call.Endpoint
                {
                    Type   = "phone",
                    number = Configuration.Instance.Settings["nexmo_number"]
                },
                Ncco = ncco
            });

            Assert.AreEqual("started", results.status);
        }
Exemple #7
0
        public IActionResult Answer()
        {
            var host = Request.Host.ToString();
            //Uncomment the next line if using ngrok with --host-header option
            //host = Request.Headers["X-Original-Host"];

            var eventUrl = $"{Request.Scheme}://{host}/webhooks/notification";

            var talkAction = new TalkAction()
            {
                Text = "Thanks for calling the notification line"
            };
            var notifyAction = new NotifyAction()
            {
                EventUrl = new[] { eventUrl },
                Payload  = new FooBar()
                {
                    Foo = "bar"
                }
            };
            var talkAction2 = new TalkAction()
            {
                Text = "You will never hear me as the notification URL will return an NCCO"
            };
            var ncco = new Ncco(talkAction, notifyAction, talkAction2);

            return(Ok(ncco.ToString()));
        }
Exemple #8
0
        public static Call.CallResponse MakeCallWithNCCO(string TO_NUMBER, string NEXMO_NUMBER)
        {
            var client = FullAuth.GetClient();

            var talkAction = new TalkAction()
            {
                Text = "This is a text to speech call from Nexmo"
            };
            var ncco = new Ncco(talkAction);

            var results = client.Call.Do(new Call.CallCommand
            {
                to = new[]
                {
                    new Call.Endpoint {
                        type   = "phone",
                        number = TO_NUMBER
                    }
                },
                from = new Call.Endpoint
                {
                    type   = "phone",
                    number = NEXMO_NUMBER
                },

                NccoObj = ncco
            });

            return(results);
        }
        public string TrackCall()
        {
            var talkAction = new TalkAction
            {
                Text = "This call will be tracked and stored using event sourcing."
            };
            var ncco = new Ncco(talkAction);

            return(ncco.ToString());
        }
Exemple #10
0
        public string Notify()
        {
            var talkAction = new TalkAction()
            {
                Text = "Hello, This is the talk action from the notify NCCO."
            };
            var ncco = new Ncco(talkAction);

            return(ncco.ToString());
        }
Exemple #11
0
        public async Task <IActionResult> OnInput()
        {
            var input = await WebhookParser.ParseWebhookAsync <MultiInput>(Request.Body, Request.ContentType);

            var talkAction = new TalkAction();

            talkAction.Text = input.Speech.SpeechResults[0].Text;
            var ncco = new Ncco(talkAction);

            return(Ok(ncco.ToString()));
        }
        public async Task <IActionResult> Dtmf()
        {
            var input      = WebhookParser.ParseWebhook <MultiInput>(Request.Body, Request.ContentType);
            var talkAction = new TalkAction()
            {
                Text = $"You Pressed {input?.Dtmf.Digits}, goodbye"
            };
            var ncco = new Ncco(talkAction);

            return(Ok(ncco.ToString()));
        }
        public void TestTalkBareBones()
        {
            var expectedJson = @"[{""text"":""Hello World"",""action"":""talk""}]";
            var talkAction   = new TalkAction
            {
                Text = "Hello World"
            };
            var ncco = new Ncco(talkAction);

            Assert.Equal(expectedJson, ncco.ToString());
        }
        public string Answer()
        {
            var talkAction = new TalkAction()
            {
                Text = $"Thank you for calling from " +
                       $"{string.Join(" ", Request.Query["from"].ToString().ToCharArray())}"
            };
            var ncco = new Ncco(talkAction);

            return(ncco.ToString());
        }
Exemple #15
0
        private Response OnAnswerInboundCall()
        {
            string number     = Request.Query["from"].Value;
            var    talkAction = new TalkAction()
            {
                Text      = ("Thank you for calling from " + string.Join(" ", number.ToCharArray())),
                VoiceName = "Kimberly"
            };
            var ncco = new Ncco(talkAction);

            return(ncco.ToString());
        }
        public async Task <ActionResult> Dtmf()
        {
            var input = await WebhookParser.ParseWebhookAsync <MultiInput>
                            (Request.Body, Request.ContentType);

            var talkAction = new TalkAction
            {
                Text = $"Thank you for inputing: {input.Dtmf.Digits}"
            };
            var ncco = new Ncco(talkAction);

            return(Ok(ncco.ToString()));
        }
Exemple #17
0
        public async Task <IActionResult> Notify()
        {
            var notification = await WebhookParser.ParseWebhookAsync <Notification <FooBar> >(Request.Body, Request.ContentType);

            Console.WriteLine($"Notification received payload's foo = {notification.Payload.Foo}");
            var talkAction = new TalkAction()
            {
                Text = "Your notification has been received, loud and clear"
            };
            var ncco = new Ncco(talkAction);

            return(Ok(ncco.ToString()));
        }
Exemple #18
0
        public string Answer()
        {
            var CONF_NAME  = Environment.GetEnvironmentVariable("CONF_NAME") ?? "CONF_NAME";
            var talkAction = new TalkAction()
            {
                Text = "Please wait while we connect you to the conference"
            };
            var conversationAction = new ConversationAction()
            {
                Name = CONF_NAME
            };
            var ncco = new Ncco(talkAction, conversationAction);

            return(ncco.ToString());
        }
        public void TestTalk()
        {
            var expectedJson = @"[{""text"":""Hello World"",""bargeIn"":""true"",""loop"":""2"",""level"":""0"",""voiceName"":""kimberly"",""action"":""talk""}]";
            var talkAction   = new TalkAction
            {
                Text      = "Hello World",
                BargeIn   = "true",
                Loop      = "2",
                Level     = "0",
                VoiceName = "kimberly"
            };
            var ncco = new Ncco(talkAction);

            Assert.Equal(expectedJson, ncco.ToString());
        }
Exemple #20
0
        private static void PerformStep(
            IDialogConfig config,
            TalkContext context,
            IEnumerable <IEntityTokeniser> tokenisers,
            Action <string> Say,
            Func <string> GetResponse
            )
        {
            bool   quit      = false;
            string humanText = null;

            do
            {
                TalkAction action = ProcessResponse(humanText, config, context, tokenisers);

                if (action is FailAction failAction)
                {
                    FailDefaultAction(config, context);
                }

                if (action is SayAction sayAction)
                {
                    // send
                    Say(sayAction.Prompt);

                    humanText = GetResponse();

                    if (string.IsNullOrEmpty(humanText))
                    {
                        break;
                    }

                    continue;
                }

                if (action is NextStepAction nextAction)
                {
                    // get next intent from the route
                    humanText = null;
                    NextStepDefaultAction(config, context);
                }

                if (context.CurrentIntent == null)
                {
                    quit = true;
                }
            } while (!quit);
        }
        //这两段是模仿Scheduler写的,主要应该是updater.RunOnce,让对话按顺序依次执行,否则会卡死
        //选了哪几门课,就会有哪些老师出来讲两句
        public static void createContinuationTalk(List <string> electiveIdList, int index)
        {
            TalkAction talkAction = new TalkAction();

            talkAction.talkId = electiveIdList[index].Replace("ec", "t") + "00_000";
            Heluo.Logger.LogError("electiveId:" + electiveIdList[index]);
            if (index < electiveIdList.Count - 1)
            {
                talkAction.onCompleted = (Action)Delegate.Combine(talkAction.onCompleted, (Action) delegate { updater.RunOnce(delegate { createContinuationTalk(electiveIdList, index + 1); }); });
            }
            else
            {
                talkAction.onCompleted = (Action)Delegate.Combine(talkAction.onCompleted, onCompletedFinal);
            }
            talkAction.Start();
        }
        public string OnInput()
        {
            MultiInput input;

            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
            {
                var result = reader.ReadToEndAsync().Result;
                input = JsonConvert.DeserializeObject <MultiInput>(result);
            }
            var talkAction = new TalkAction();

            talkAction.Text = input.Speech.SpeechResults[0].Text;
            var ncco = new Ncco(talkAction);

            return(ncco.ToString());
        }
Exemple #23
0
        private Response OnAnswerConference()
        {
            var talkNcco = new TalkAction()
            {
                Text      = "Hello. You will now be added to the conference call.",
                VoiceName = "Emma"
            };

            var conferenceNcco = new ConversationAction()
            {
                Name = "conference-call"
            };

            var ncco = new Ncco(talkNcco, conferenceNcco);

            return(ncco.ToString());
        }
Exemple #24
0
        private Response OnAnswerDtmf()
        {
            var talkAction = new TalkAction()
            {
                Text = "Hello. Please Press Any Key To continue"
            };

            var inputAction = new InputAction()
            {
                MaxDigits = "1",
                TimeOut   = "6",
                EventUrl  = new [] { $"{SiteBase}/webhook/dtmf" }
            };

            var ncco = new Ncco(talkAction, inputAction);

            return(ncco.ToString());
        }
Exemple #25
0
        private Response OnAnswerRecordConversation()
        {
            var talkAction = new TalkAction()
            {
                Text      = "Thank you for calling. You will now be joined into the conference",
                VoiceName = "Kimberly"
            };

            var conversationAction = new ConversationAction()
            {
                Name        = "A_Conference",
                Record      = "True",
                EventMethod = "POST",
                EventUrl    = new [] { $"{SiteBase}/webhook/record" }
            };
            var ncco = new Ncco(talkAction, conversationAction);

            return(ncco.ToString());
        }
Exemple #26
0
        private string OnRecordComplete()
        {
            var recordEvent = EventBase.ParseEvent(Request.Body.AsString()) as Record;

            if (recordEvent != null)
            {
                Debug.WriteLine($"Recording URL: {recordEvent.RecordingUrl}");
            }

            var talkAction = new TalkAction()
            {
                Text      = "Thank you for calling in the recording is now finished, have a nice day",
                VoiceName = "Kimberly"
            };

            var ncco = new Ncco(talkAction);

            return(ncco.ToString());
        }
Exemple #27
0
        private Response GetDTMFInput()
        {
            var input = EventBase.ParseEvent(Request.Body.AsString()) as Input;

            var talkNcco = new TalkAction();

            if (input != null)
            {
                talkNcco.Text = $"You pressed {input.Dtmf}";
            }
            else
            {
                talkNcco.Text = "No input received";
            }

            var ncco = new Ncco(talkNcco);

            return(ncco.ToString());
        }
        public ActionResult Answer()
        {
            var responseUrl = $"{Request.Scheme}://{Request.Host}/webhooks/dtmf";
            var talkAction  = new TalkAction
            {
                Text    = "Hello please enter a digit.",
                BargeIn = "true"
            };
            var inputAction = new MultiInputAction
            {
                Dtmf = new DtmfSettings {
                    MaxDigits = 1
                },
                EventUrl    = new[] { responseUrl },
                EventMethod = "POST"
            };
            var ncco = new Ncco(talkAction, inputAction);

            return(Ok(ncco.ToString()));
        }
Exemple #29
0
        public static Call.CallResponse TransferCallWithInlineNCCO(string UUID)
        {
            var client     = FullAuth.GetClient();
            var talkAction = new TalkAction()
            {
                Text = "This is a transfer action using an inline NCCO"
            };
            var ncco     = new Ncco(talkAction);
            var response = client.Call.Edit(UUID,
                                            new Call.CallEditCommand()
            {
                Action      = "transfer",
                Destination = new Call.Destination()
                {
                    Type = "ncco",
                    Ncco = ncco
                }
            });

            return(response);
        }
Exemple #30
0
        private Response OnAnswerConnect()
        {
            var talkAction = new TalkAction()
            {
                Text      = "Thank you for calling",
                VoiceName = "Kimberly"
            };
            var phoneEndpoint = new PhoneEndpoint()
            {
                Number = "TO_NUMBER"
            };
            var connectAction = new ConnectAction()
            {
                From     = Request.Query.from.Value,
                Endpoint = new[] { phoneEndpoint }
            };

            var ncco = new Ncco(talkAction, connectAction);

            return(ncco.ToString());
        }