Пример #1
0
        public SkillResponse Execute()
        {
            var intent = IntentFactory.Get(SkillRequest);

            SkillResponse = (IsValidIntent() && intent.ParseAndValidate()) ? intent.Execute() : intent.SkillResponse;
            return(SkillResponse);
        }
Пример #2
0
        public void Dial()
        {
            try
            {
                this.SetStatusUI(true);

                Settings setting = SimpleIoc.Default.GetInstance <Settings>();

                if (string.IsNullOrWhiteSpace(setting.NumberToDial))
                {
                    return;
                }
                string numberToDial     = setting.NumberToDial;
                bool   enableSkypeVideo = setting.IsSkypeVideoEnabled;

                SimpleIoc.Default.GetInstance <INotifiedOnCalling>().CallStarts();

                switch (setting.CallType)
                {
                case SettingsTable.CallTypeEnum.SkypeUser:
                {
                    Intent skypeintent = IntentFactory.GetSkypeUserIntent(numberToDial, enableSkypeVideo);
                    base.StartActivity(skypeintent);
                    break;
                }

                case SettingsTable.CallTypeEnum.SkypeOut:
                {
                    Intent skypeintent = IntentFactory.GetSkypeOutIntent(numberToDial);
                    base.StartActivity(skypeintent);
                    break;
                }

                case SettingsTable.CallTypeEnum.Phone:
                default:
                {
                    try
                    {
                        Intent phoneIntent = IntentFactory.GetCallPhoneIntent(numberToDial, true);
                        base.StartActivity(phoneIntent);
                    }
                    catch (ActivityNotFoundException)
                    {
                        // if setting the package doesn't work, call without it
                        Intent phoneIntent = IntentFactory.GetCallPhoneIntent(numberToDial, false);
                        base.StartActivity(phoneIntent);
                    }

                    break;
                }
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Long);
            }
        }
Пример #3
0
        private IntentParameters SetupFunction(SkillRequest input, ILambdaContext context)
        {
            _intentFactory = IntentFactory();

            var parameters = BuildParameters(context.Logger, input.Session, input.Context?.System?.Device);

            _container = BuildContainer(_intentFactory, parameters);

            AlexaContext = new AlexaContext(_container);

            _intentFactory.BuildIntents(parameters, _container);

            return(parameters);
        }
Пример #4
0
        private IContainer BuildContainer(IntentFactory intentFactory, IntentParameters parameters)
        {
            var builder = new ContainerBuilder();

            builder.Register(a => parameters);

            builder.Register(a => intentFactory).SingleInstance();

            builder.Register(a => IntentNames() ?? new IntentNames()).SingleInstance();

            intentFactory.RegisterIntents(builder);

            RegisterDependencies(builder, parameters);

            return(builder.Build());
        }
Пример #5
0
 void chooseContactButton_Click(object sender, EventArgs e)
 {
     IntentFactory.StartActivityWithNoHistory <ChooseSkypeOrTelephoneActivity>(this);
 }
Пример #6
0
 public DefaultDebugIntent(IntentFactory intentFactory)
 {
     _intentFactory = intentFactory;
 }
Пример #7
0
 public QuestionNeedingResponseIntent(IntentFactory intentFactory)
 {
     _intentFactory = intentFactory;
 }
Пример #8
0
 public AlexaFunctionRunner(IntentFactory intentFactory, string noIntentMatchedText)
 {
     _intentFactory = intentFactory;
     _noIntentMatchedText = noIntentMatchedText;
 }
Пример #9
0
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context)
        {
            var response = new SkillResponse
            {
                Response = new ResponseBody
                {
                    ShouldEndSession = false
                }
            };

            IOutputSpeech innerResponse = null;

            var logger = context.Logger;

            logger.LogLine("Skill Request Object:");
            logger.LogLine(JsonConvert.SerializeObject(input));

            var resource = MonzoResourceHelper.GetResources(input.Request.Locale);

            if (input.GetRequestType() == typeof(LaunchRequest))
            {
                logger.LogLine("Default LaunchRequest made: 'Alexa, open Monzo");
                innerResponse = new PlainTextOutputSpeech
                {
                    Text = resource.HelpMessage
                };
                response.Response.ShouldEndSession = false;
            }
            else if (input.GetRequestType() == typeof(IntentRequest))
            {
                var    accessToken = input.Session.User.AccessToken;
                string message;
                if (!string.IsNullOrEmpty(accessToken))
                {
                    var intentRequest = (IntentRequest)input.Request;

                    var inputJson = JsonConvert.SerializeObject(input);

                    logger.LogLine($"Logging Input: {inputJson}");


                    var intentFactory = new IntentFactory(accessToken, logger);

                    logger.LogLine($"{intentRequest.Intent.Name}");

                    var activatedIntent = intentFactory.GetIntent(intentRequest.Intent.Name);

                    message = activatedIntent.Execute(intentRequest.Intent, resource);
                    response.Response.ShouldEndSession = activatedIntent.ShouldEndSession;
                }
                else
                {
                    message = "I'm sorry, I'm unable to communicate with the Monzo server. Please try again later.";
                    response.Response.ShouldEndSession = true;
                }

                innerResponse = new PlainTextOutputSpeech();
                (innerResponse as PlainTextOutputSpeech).Text = message;
            }

            response.Response.OutputSpeech = innerResponse;
            response.Version = "1.0";
            logger.LogLine("Skill Response Object...");
            logger.LogLine(JsonConvert.SerializeObject(response));
            return(response);
        }