Esempio n. 1
0
        public static SpeechletResponse CompileResponse(string output)
        {
            //var response = new SpeechletResponse
            //{
            //    OutputSpeech = new PlainTextOutputSpeech { Text = output },
            //    ShouldEndSession = true
            //};
            //return response;

            var card = new SimpleCard {
                Title = "Home Tips"
            };

            var textInfo = new CultureInfo("en-US", false).TextInfo;

            card.Content = textInfo.ToTitleCase(output);

            // Create the plain text output.
            var speech = new PlainTextOutputSpeech {
                Text = output
            };

            // Create the speechlet response.
            var response = new SpeechletResponse
            {
                ShouldEndSession = true,
                OutputSpeech     = speech,
                Card             = card
            };

            return(response);
        }
Esempio n. 2
0
        private SkillResponse AllPaleoFood(SkillRequest input, IntentRequest intentRequest, SsmlOutputSpeech speech)
        {
            SkillResponse finalResponse;
            // get the slots

            // create the speech response - cards still need a voice response
            var foodlist = string.Empty;

            foreach (var item in GetPaleoFoods())
            {
                foodlist += item + ",";
            }
            foodlist = foodlist.Remove(foodlist.Length - 1, 1);
            var paleofoodlist = $"These are the paleo foods: {foodlist}";

            speech.Ssml = $"<speak>{paleofoodlist}! Would you like to know more about paleo activities?</speak>";

            // create the speech reprompt
            var repromptMessage = new PlainTextOutputSpeech();

            repromptMessage.Text = "Would you like to know more paleo about activities?";

            input.Session.Attributes["paleoActivities"] = "true";


            // create the reprompt
            var repromptBody = new Reprompt();

            repromptBody.OutputSpeech = repromptMessage;

            // create the response
            finalResponse = ResponseBuilder.Ask(speech, repromptBody, input.Session);

            return(finalResponse);
        }
Esempio n. 3
0
        private IOutputSpeech ProcessIntentRequest(SkillRequest input)
        {
            var           intentRequest = input.Request;
            IOutputSpeech innerResponse = new PlainTextOutputSpeech();

            switch (intentRequest.Intent.Name)
            {
            case AlexaConstants.CancelIntent:
                (innerResponse as PlainTextOutputSpeech).Text = "";
                response.Response.ShouldEndSession            = true;
                break;

            case AlexaConstants.StopIntent:
                (innerResponse as PlainTextOutputSpeech).Text = "";
                response.Response.ShouldEndSession            = true;
                break;

            case AlexaConstants.HelpIntent:
                (innerResponse as PlainTextOutputSpeech).Text = "";
                break;



            default:
                (innerResponse as PlainTextOutputSpeech).Text = "";
                break;
            }
            if (innerResponse.Type == AlexaConstants.SSMLSpeech)
            {
                (innerResponse as SsmlOutputSpeech).Ssml = "";
            }
            return(innerResponse);
        }
Esempio n. 4
0
        // This is the method that is being invoked. This is the main method that will parse the intent and generate the result.
        public SkillResponse Post([FromBody] SkillRequest request)
        {
            SkillResponse response = null;

            if (request != null)
            {
                PlainTextOutputSpeech outputSpeech = new PlainTextOutputSpeech();
                string Item = (request.Request as IntentRequest)?.Intent.Slots.FirstOrDefault(s => s.Key == "Item").Value.Value.ToString();
                if (Item.ToUpper() == "Bread".ToUpper())
                {
                    outputSpeech.Text = Item + " Ingredients are wheat flour , water";
                }

                else if (Item.ToUpper() == "Cookie".ToUpper())
                {
                    outputSpeech.Text = Item + " Ingredients are flour ,Sugar, Egg and vanilla";
                }
                else if (Item.ToUpper() == "Sandwich".ToUpper())
                {
                    outputSpeech.Text = Item + " Ingredients are Bread, Lettuce, Tomato";
                }
                else if (Item.ToUpper() == "Biryani".ToUpper())
                {
                    outputSpeech.Text = Item + " Ingredients are Rice, Vegetable, Spices";
                }
                else
                {
                    outputSpeech.Text = " I am not an expert at cooking " + Item + " but i am learning. Will let you know in a few Hours.";
                }

                response = ResponseBuilder.Tell(outputSpeech);
            }
            return(response);
        }
Esempio n. 5
0
        /**
         * Creates and returns the visual and spoken response with shouldEndSession flag
         *
         * @param title
         *            title for the companion application home card
         * @param output
         *            output content for speech and companion application home card
         * @param shouldEndSession
         *            should the session be closed
         * @return SpeechletResponse spoken and visual response for the given input
         */
        private SpeechletResponse BuildSpeechletResponse(string title, string output, bool shouldEndSession)
        {
            // Create the Simple card content.
            var consentCard = new AskForPermissionsConsentCard();

            consentCard.PermissionType = PermissionType.CountryAndPostalCode;


            SimpleCard card = new SimpleCard();

            card.Title    = String.Format("SessionSpeechlet - {0}", title);
            card.Subtitle = String.Format("SessionSpeechlet - Sub Title");
            card.Content  = String.Format("SessionSpeechlet - {0}", output);

            // Create the plain text output.
            PlainTextOutputSpeech speech = new PlainTextOutputSpeech();

            speech.Text = output;

            // Create the speechlet response.
            SpeechletResponse response = new SpeechletResponse();

            response.ShouldEndSession = shouldEndSession;
            response.OutputSpeech     = speech;
            response.Card             = card;
            return(response);
        }
Esempio n. 6
0
        private static SkillResponse ProcessLaunch(SkillRequest input)
        {
            var response = new SkillResponse
            {
                Response = new ResponseBody {
                    ShouldEndSession = false, OutputSpeech = new PlainTextOutputSpeech
                    {
                        Text = "Ready"
                    }
                },

                Version = AlexaConstants.AlexaVersion
            };

            var locale = input.Request.Locale;

            if (string.IsNullOrEmpty(locale))
            {
                locale = USA_Locale;
            }

            IOutputSpeech prompt = new PlainTextOutputSpeech();

            (prompt as PlainTextOutputSpeech).Text = "Hello";
            response.Response.OutputSpeech         = prompt;
            response.SessionAttributes             = new Dictionary <string, object>()
            {
                { LOCALENAME, locale }
            };

            return(response);
        }
        /// <summary>
        /// Creates a response object
        /// </summary>
        /// <param name="response"></param>
        /// <param name="title"></param>
        /// <param name="cardContent"></param>
        /// <param name="session"></param>
        /// <param name="endSession"></param>
        /// <returns>the respnse</returns>
        private static SkillResponse CreateResponseWithReprompt(string response, string title, string cardContent, Session session)
        {
            var respMessage = new PlainTextOutputSpeech();

            respMessage.Text = response;

            var repromptMessage = new PlainTextOutputSpeech();

            repromptMessage.Text = "Soll ich dir noch einen Geburtstag sagen?";
            var repromptBody = new Reprompt();

            repromptBody.OutputSpeech = repromptMessage;

            ResponseBody body = new ResponseBody();

            body.OutputSpeech     = respMessage;
            body.ShouldEndSession = false;
            body.Card             = new SimpleCard {
                Title = title, Content = response
            };
            body.Reprompt = repromptBody;

            //SkillResponse resp = ResponseBuilder.TellWithCard(response, title, response);
            SkillResponse resp = new SkillResponse();

            resp.Response          = body;
            resp.Version           = "1.0";
            resp.SessionAttributes = session.Attributes;
            return(resp);
        }
Esempio n. 8
0
        protected SpeechletResponse BuildSpeechletResponse(string title, string output, bool shouldEndSession)
        {
            // Create the Simple card content.
            var card = new SimpleCard
            {
                Title   = String.Format("SessionSpeechlet - {0}", title),
                Content = String.Format("SessionSpeechlet - {0}", output)
            };

            // Create the plain text output.
            var speech = new PlainTextOutputSpeech
            {
                Text = output
            };

            // Create the speechlet response.
            var response = new SpeechletResponse
            {
                ShouldEndSession = shouldEndSession,
                OutputSpeech     = speech,
                Card             = card
            };

            return(response);
        }
        /// <summary>
        ///  build the speech response
        /// </summary>
        /// <param name="title"></param>
        /// <param name="output"></param>
        /// <param name="reprompt"></param>
        /// <param name="shouldEndSession"></param>
        /// <returns>void</returns
        private void BuildSpeechResponse(string title, string speechOutput, string reprompt, bool shouldEndSession)
        {
            if (title != string.Empty)
            {
                // Create the Simple card content.
                SimpleCard card = new SimpleCard();
                card.Title   = title;
                card.Content = reprompt;
                skillResponse.Response.Card = card;
            }

            // create the speech response
            IOutputSpeech speechMessage = new PlainTextOutputSpeech();

            (speechMessage as PlainTextOutputSpeech).Text = speechOutput;

            if (reprompt != string.Empty)
            {
                PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
                speech.Text = reprompt;
                skillResponse.Response.Reprompt = new Reprompt();
                skillResponse.Response.Reprompt.OutputSpeech = speech;
            }
            skillResponse.Response.OutputSpeech     = speechMessage;
            skillResponse.Response.ShouldEndSession = shouldEndSession;
        }
Esempio n. 10
0
        private SkillResponse FirstStep(SkillRequest input, ILambdaContext context, IntentRequest intentRequest, SsmlOutputSpeech speech)
        {
            SkillResponse finalResponse;

            // get the slots
            // create the speech response - cards still need a voice response
            speech.Ssml = $"<speak>As a first step, " +
                          $"visit a nearest blood test center to undergo the paleo blood test " +
                          $"and post your reports in the official Facebook page! " +
                          $"Volunteers will respond back with a diet chart based on your reports. Would you like to know the list of paleo foods?</speak>";

            // create the speech reprompt
            var repromptMessage = new PlainTextOutputSpeech();

            repromptMessage.Text = "Would you like to know the list of paleo foods?";

            input.Session.Attributes["paleofoodlist"] = "true";
            //var yesIntentValuePaleofoodlist = Convert.ToBoolean(input.Session.Attributes["paleofoodlist"]);
            //var yesIntentValueStartPaleoDiet = Convert.ToBoolean(input.Session.Attributes["startpaleodiet"]);

            //context.Logger.Log("FirstStep " + yesIntentValuePaleofoodlist.ToString());
            //context.Logger.Log("FirstStep " + yesIntentValueStartPaleoDiet.ToString());

            // create the reprompt
            var repromptBody = new Reprompt();

            repromptBody.OutputSpeech = repromptMessage;

            // create the response
            finalResponse = ResponseBuilder.Ask(speech, repromptBody, input.Session);

            return(finalResponse);
        }
        async public override Task <SkillResponse> HandleIntentRequest(IntentRequest request)
        {
            var log = curContext.Logger;

            StringBuilder vidSources     = new StringBuilder();
            List <string> listVidSources = vidSrcHandler.GetAvailableVidSources();
            await Task.Run(() => {
                for (int index = 0; index < listVidSources.Count; index++)
                {
                    if (index == listVidSources.Count - 1)
                    {
                        vidSources.AppendLine(String.Format(" {0} {1}", "and", listVidSources[index]));
                    }
                    else
                    {
                        vidSources.AppendLine(listVidSources[index]);
                    }
                    //vidSrcHandler.GetAvailableVidSources().ForEach(vidSrc => vidSources.AppendLine(vidSrc));
                }
            });

            outSpeech = new PlainTextOutputSpeech();
            //(outSpeech as PlainTextOutputSpeech).Text = "Alright!. I have sent a message to venue system to push " + monVidSrcSlot.Value + " on " + monLocSlot.Value + " Monitor.";
            (outSpeech as PlainTextOutputSpeech).Text = "Currently available video sources in your aircraft are \n" + vidSources.ToString();
            skillResponse.Response.OutputSpeech       = outSpeech;
            skillResponse.Response.ShouldEndSession   = false;

            return(skillResponse);
        }
Esempio n. 12
0
        private SkillResponse TakeTurn(Intent intent, Session session)
        {
            var nextValue = new Random().Next(0, Cards.Length);
            var nextCard  = Cards[nextValue];

            var actual   = (int)session.Attributes["value"] < nextValue ? "higher" : "lower";
            var expected = intent.Slots["choice"].Value;

            if (actual != expected)
            {
                return(WrongGuess(nextCard, (int)session.Attributes["count"]));
            }

            var currentCount = (int)session.Attributes["count"];

            session.Attributes["count"] = currentCount + 1;
            var speech = new PlainTextOutputSpeech {
                Text = $"Well done. It was a {nextCard}. So is the next card higher or lower than a  {nextCard}?"
            };

            return(ResponseBuilder.AskWithCard(
                       speech,
                       "Correct Guess!",
                       $"Well done. The next card is a {nextCard}",
                       null,
                       session));
        }
Esempio n. 13
0
        private SkillResponse PaleoActivities(SkillRequest input, IntentRequest intentRequest, SsmlOutputSpeech speech)
        {
            SkillResponse finalResponse;

            // get the slots

            // create the speech response - cards still need a voice response
            speech.Ssml = $"<speak>{GetRandomResponse(false)}! Still you need to know more?</speak>";

            // create the speech reprompt
            var repromptMessage = new PlainTextOutputSpeech();

            repromptMessage.Text = "Still you need to know more?";

            input.Session.Attributes["paleoActivities"] = "true";


            // create the reprompt
            var repromptBody = new Reprompt();

            repromptBody.OutputSpeech = repromptMessage;

            // create the response
            finalResponse = ResponseBuilder.Ask(speech, repromptBody, input.Session);

            return(finalResponse);
        }
Esempio n. 14
0
        public SkillResponse CancelIntent(SkillRequest input, ILambdaContext context, SkillResource resource)
        {
            var log = context.Logger;
            SkillResponse
                response = new SkillResponse
            {
                Response = new ResponseBody {
                    ShouldEndSession = true
                }
            };     //sets up the skill speech response format


            //Setting Speech Response
            IOutputSpeech innerSpeechResponse = new PlainTextOutputSpeech();

            if (resource != null)
            {
                //Setting Speech Response
                ((PlainTextOutputSpeech)innerSpeechResponse).Text = resource.StopMessage;
                // Setting App Card
                var card = SetStandardCard("GoodBye", resource.StopMessage,
                                           SetCardImage(
                                               "https://raw.githubusercontent.com/fuzzysb/Accrington-Academy/master/Accrington-Academy/AccringtonAcademy-Small.png",
                                               "https://raw.githubusercontent.com/fuzzysb/Accrington-Academy/master/Accrington-Academy/AccringtonAcademy-Large.png"));
                response.Response.Card = card;
            }

            //Add Speech
            response.Response.OutputSpeech = innerSpeechResponse;
            response.Version = "1.0";
            log.LogLine("Skill Response Object...");
            log.LogLine(JsonConvert.SerializeObject(response));
            return(response);
        }
        private SpeechletResponse BuildSpeechletResponse(string title, string output, bool shouldEndSession)
        {
            // Create the Simple card content.
            SimpleCard card = new SimpleCard();

            card.Title = title;
            TextInfo textInfo = new CultureInfo("en-GB", false).TextInfo;

            card.Content = textInfo.ToTitleCase(output);

            // Create the plain text output.
            PlainTextOutputSpeech speech = new PlainTextOutputSpeech();

            speech.Text = output;

            // Create the speechlet response.
            SpeechletResponse response = new SpeechletResponse();

            response.ShouldEndSession = shouldEndSession;
            response.OutputSpeech     = speech;
            response.Card             = card;
            Reprompt reprompt = new Reprompt()
            {
                OutputSpeech = speech
            };

            response.Reprompt = reprompt;
            return(response);
        }
        public SkillResponse Handle(IntentRequest intentRequest, ILambdaContext context, Session session)
        {
            if (IsDialogIntentRequest(intentRequest))
            {
                if (IsDialogSequenceComplete(intentRequest) == false)
                {
                    return(ResponseBuilder.DialogDelegate(session));
                }
            }

            var intent             = intentRequest.Intent;
            var dateSlotValue      = intent.Slots["date"].Value;
            var clubNameSlotValue  = intent.Slots["clubName"].Value;
            var classNameSlotValue = intent.Slots["className"].Value;

            var date = NodaTime.AmazonDate.AmazonDateParser.Parse(dateSlotValue);

            var dateFrom = date.From.ToDateTimeUnspecified();
            var dateTo   = date.To.ToDateTimeUnspecified();

            if (dateFrom == dateTo)
            {
                dateFrom = new DateTime(dateFrom.Year, dateFrom.Month, dateFrom.Day, 0, 0, 0);
                dateTo   = new DateTime(dateTo.Year, dateTo.Month, dateTo.Day, 23, 59, 59);
            }

            var goApiClient = new GoApiClient();
            var result      = goApiClient.UpcomingClasses(classNameSlotValue, clubNameSlotValue, dateFrom, dateTo).Result;

            if (result.Errors.Any())
            {
                return(ResponseBuilder.Tell($"{result.Errors.First().Message}"));
            }



            var bookingsResponse = string.Join(',', result.Data.OrderBy(x => x.StartDate).
                                               Select(x =>
            {
                var startDate = x.StartDate.ToString("dddd dd MMMM hh:mm tt",
                                                     CultureInfo.CreateSpecificCulture("en-US"));
                return($" {x.ClassName} on {startDate}");
            }));

            var speech = new SsmlOutputSpeech {
                Ssml = $"<speak>{ GetFirstPartResponse(result.Data.Count())}{ bookingsResponse}</speak>"
            };
            var repromptMessage = new PlainTextOutputSpeech {
                Text = "Would you like to book one ?"
            };
            var repromptBody = new Reprompt();

            repromptBody.OutputSpeech = repromptMessage;
            var finalResponse = ResponseBuilder.Ask(speech, repromptBody);

            return(finalResponse);

            //return ResponseBuilder.Ask($"{GetFirstPartResponse(result.Data.Count())}{bookingsResponse}",
            //    new Reprompt("Whould you like to book one? "));
        }
        private async Task <SpeechletResponse> BuildSpeechletResponse(string title, string output, bool shouldEndSession)
        {
            //Create a standard card
            var image = new Image()
            {
                SmallImageUrl = "https://samman.hopto.org/rokusmall.png",
                LargeImageUrl = "https://samman.hopto.org/rokubig.png"
            };

            var card = new StandardCard()
            {
                Title = String.Format("RokuControl - {0}", title),
                Text  = String.Format("{0}", output),
                Image = image
            };

            // Create the plain text output.
            var speech = new PlainTextOutputSpeech()
            {
                Text = output
            };

            // Create the speechlet response.
            var response = new SpeechletResponse()
            {
                ShouldEndSession = shouldEndSession,
                OutputSpeech     = speech,
                Card             = card
            };

            return(response);
        }
        protected override SkillResponse Handle(IntentRequest intentRequest, Session session, Context context)
        {
            if (intentRequest.Intent.Slots.TryGetValue("participant", out var Participant) && !string.IsNullOrEmpty(Participant.Value))
            {
                var responseSession = new Session
                {
                    Attributes = new Dictionary <string, object>
                    {
                        { "participant", Participant.Value },
                        { "state", IntentState.ParticipantAdd }
                    }
                };
                var anwser = new PlainTextOutputSpeech {
                    Text = $"Soll {Participant.Value} hinzugefügt werden?"
                };
                var repompt = new Reprompt
                {
                    OutputSpeech = new PlainTextOutputSpeech {
                        Text = $"{Participant.Value} hinzufügen"
                    }
                };
                return(ResponseBuilder.Ask(anwser, repompt, responseSession));
            }

            return(ResponseBuilder.Tell("Es wurde kein Benutzer übergeben"));
        }
Esempio n. 19
0
        private async Task <SkillResponse> HandleGiveFactIntentRequestAsync(IntentRequest intentRequest)
        {
            var topic = intentRequest.Intent.Slots["topic"]?.Value;

            if (topic != null)
            {
                var fact = await _db.RandomFactAsync(topic);

                if (fact == null)
                {
                    return(ResponseBuilder.Tell($"Zum Thema {topic} habe ich leider nichts gefunden."));
                }

                var speech = new PlainTextOutputSpeech
                {
                    Text = $"Zum Thema {topic} habe ich Folgendes gefunden: {fact.Value}"
                };
                return(ResponseBuilder.Tell(speech));
            }
            else
            {
                var info = await _db.RandomFactAsync();

                var speech = new PlainTextOutputSpeech
                {
                    Text = $"Hier ein interessanter Fakt über Paderborn: {info.Value}"
                };
                return(ResponseBuilder.Tell(speech));
            }
        }
Esempio n. 20
0
        /**
         * Creates and returns the visual and spoken response with shouldEndSession flag
         *
         * @param title
         *            title for the companion application home card
         * @param output
         *            output content for speech and companion application home card
         * @param shouldEndSession
         *            should the session be closed
         * @return SpeechletResponse spoken and visual response for the given input
         */

        private SpeechletResponse BuildSpeechletResponse(string title, string output, bool shouldEndSession)
        {
            // Create the Simple card content.
            var card = new SimpleCard
            {
                Title = "Unidesk Dishwasher",
                //Subtitle = "Unidesk Dishwasher - Sub Title",
                Content = $"Unidesk Diskwasher - {output}"
            };

            // Create the plain text output.
            var speech = new PlainTextOutputSpeech {
                Text = output
            };

            // Create the speechlet response.
            var response = new SpeechletResponse
            {
                ShouldEndSession = shouldEndSession,
                OutputSpeech     = speech,
                Card             = card
            };

            return(response);
        }
Esempio n. 21
0
        /**
         * Creates and returns the visual and spoken response with shouldEndSession flag
         *
         * @param title
         *            title for the companion application home card
         * @param output
         *            output content for speech and companion application home card
         * @param shouldEndSession
         *            should the session be closed
         * @return SpeechletResponse spoken and visual response for the given input
         */
        private SpeechletResponse BuildSpeechletResponse(string title, string output, string reprompt_out, bool shouldEndSession)
        {
            // Create the Simple card content.
            SimpleCard card = new SimpleCard();

            card.Title    = String.Format(title);
            card.Subtitle = String.Format("Star Citizen");
            card.Content  = String.Format(output);

            // Create the plain text output.
            PlainTextOutputSpeech speech = new PlainTextOutputSpeech();

            speech.Text = output;

            PlainTextOutputSpeech reprompt_speech = new PlainTextOutputSpeech();

            reprompt_speech.Text = reprompt_out;



            // Create the speechlet response.
            SpeechletResponse response = new SpeechletResponse();

            response.ShouldEndSession = shouldEndSession;
            response.OutputSpeech     = speech;
            response.Card             = card;
            //if (!shouldEndSession)
            //{
            response.Reprompt.OutputSpeech = reprompt_speech;
            //    return response;
            //}

            return(response);
        }
Esempio n. 22
0
        /// <summary>
        /// Returns bus times
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context)
        {
            SkillResponse response = new SkillResponse
            {
                Response = new ResponseBody()
            };

            response.Response.ShouldEndSession = false;
            IOutputSpeech innerResponse = null;
            var           log           = context.Logger;

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

            //foreach (TimeZoneInfo z in TimeZoneInfo.GetSystemTimeZones())
            //    log.LogLine(z.Id);

            if (input.GetRequestType() == typeof(LaunchRequest))
            {
                log.LogLine($"Default LaunchRequest made: 'Alexa, open Busplan");
                innerResponse = new PlainTextOutputSpeech();
                (innerResponse as PlainTextOutputSpeech).Text =
                    GetNextBusAnnouncement(Moltkestrasse, Uni) +
                    GetNextBusAnnouncement(Moltkestrasse, Bahnhof);
                response.Response.ShouldEndSession = true;
            }
            else if (input.GetRequestType() == typeof(IntentRequest))
            {
                var intentRequest = (IntentRequest)input.Request;

                switch (intentRequest.Intent.Name)
                {
                case "AMAZON.CancelIntent":
                case "AMAZON.StopIntent":
                    log.LogLine($"{intentRequest.Intent.Name}: send StopMessage");
                    innerResponse = new PlainTextOutputSpeech();
                    (innerResponse as PlainTextOutputSpeech).Text = "Stopped";
                    response.Response.ShouldEndSession            = true;
                    break;

                case "AMAZON.HelpIntent":
                    log.LogLine($"AMAZON.HelpIntent: send HelpMessage");
                    innerResponse = new PlainTextOutputSpeech();
                    (innerResponse as PlainTextOutputSpeech).Text = "Help";
                    break;

                default:
                    log.LogLine($"default intent: " + intentRequest.Intent.Name);
                    innerResponse = new PlainTextOutputSpeech();
                    (innerResponse as PlainTextOutputSpeech).Text = "default";
                    break;
                }
            }

            response.Response.OutputSpeech = innerResponse;
            response.Version = "1.0";
            log.LogLine($"Skill Response Object...");
            log.LogLine(JsonConvert.SerializeObject(response));
            return(response);
        }
Esempio n. 23
0
        public void SerializesPlainTextOutputSpeechWithPlayBehaviorToJson()
        {
            var plainTextOutputSpeech = new PlainTextOutputSpeech {
                Text = "text content", PlayBehavior = PlayBehavior.ReplaceAll
            };

            Assert.True(Utility.CompareJson(plainTextOutputSpeech, "PlainTextOutputSpeechWithPlayBehavior.json"));
        }
Esempio n. 24
0
        public void SerializesPlainTextOutputSpeechToJson()
        {
            var plainTextOutputSpeech = new PlainTextOutputSpeech {
                Text = "text content"
            };

            Assert.True(Utility.CompareJson(plainTextOutputSpeech, "PlainTextOutputSpeech.json"));
        }
Esempio n. 25
0
        private SkillResponse InvalidIntent()
        {
            var speech = new PlainTextOutputSpeech {
                Text = "Sorry, that's not part of the game. Try again?"
            };

            return(ResponseBuilder.Ask(speech, null));
        }
Esempio n. 26
0
        private IOutputSpeech GetLaunchRequest()
        {
            IOutputSpeech innerResponse = new PlainTextOutputSpeech();

            (innerResponse as PlainTextOutputSpeech).Text = WELCOME_MESSAGE;

            return(innerResponse);
        }
Esempio n. 27
0
 public SpeechletResponse Say(PlainTextOutputSpeech speechOutput, bool shouldEndSession = true)
 {
     return(new SpeechletResponse()
     {
         OutputSpeech = speechOutput,
         ShouldEndSession = shouldEndSession
     });
 }
Esempio n. 28
0
        public static SpeechletResponse BuildSpeechletResponse(SimpleIntentResponse simpleIntentResponse, bool shouldEndSession)
        {
            SpeechletResponse response = new SpeechletResponse();

            response.ShouldEndSession = shouldEndSession;

            // Create the speechlet response from SimpleIntentResponse.
            // If there's an ssmlString use that as the spoken reply
            // If ssmlString is empty, speak cardText

            if (simpleIntentResponse.ssmlString != "")
            {
                SsmlOutputSpeech speech = new SsmlOutputSpeech();
                speech.Ssml           = simpleIntentResponse.ssmlString;
                response.OutputSpeech = speech;
            }
            else
            {
                PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
                speech.Text           = simpleIntentResponse.cardText;
                response.OutputSpeech = speech;
            }


            // if images are passed, then assume a standard card is wanted
            // images should be stored in the ~/Images/ folder and follow these requirements

            // JPEG or PNG supported, no larger than 2MB
            // 720x480 - small size recommendation
            // 1200x800 - large size recommendation

            if (simpleIntentResponse.smallImage != "" && simpleIntentResponse.largeImage != "")
            {
                StandardCard card = new StandardCard();
                card.Title = AlexaConstants.AppName;
                card.Text  = simpleIntentResponse.cardText;

                // The trailing slash after the image name is required because we're serving off the image through a Web API controller and
                // don't want to change the default web project settings

                card.Image = new Image()
                {
                    LargeImageUrl = "https://" + System.Web.HttpContext.Current.Request.Url.Host + "/api/alexaimages/" + simpleIntentResponse.largeImage + "/",
                    SmallImageUrl = "https://" + System.Web.HttpContext.Current.Request.Url.Host + "/api/alexaimages/" + simpleIntentResponse.smallImage + "/",
                };

                response.Card = card;
            }
            else
            {
                SimpleCard card = new SimpleCard();
                card.Title    = AlexaConstants.AppName;
                card.Content  = simpleIntentResponse.cardText;
                response.Card = card;
            }

            return(response);
        }
Esempio n. 29
0
        private SkillResponse EndGame(Session session)
        {
            var final  = (int)session.Attributes["count"];
            var speech = new PlainTextOutputSpeech {
                Text = $"No problem. Your final score was {final} correct guesses"
            };

            return(ResponseBuilder.TellWithCard(speech, "Final Score", $"{final} correct guesses"));
        }
Esempio n. 30
0
        private SkillResponse WrongGuess(string nextCard, int count)
        {
            var speech = new PlainTextOutputSpeech
            {
                Text = $"Sorry, but the card was a {nextCard}. You managed to get {count} correct guesses"
            };

            return(ResponseBuilder.Tell(speech));
        }