示例#1
0
        private AlexaResponse IntentRequestHandler(AlexaRequest.RequestAttributes request)
        {
            var output = new StringBuilder();

            switch (request.Intent.Name)
            {
            case "PromotionsIntent":
                output.Append("Here are our pure tasty and cheap promos!");
                foreach (var promotion in promotions)
                {
                    output.Append("\n");
                    output.Append(promotion);
                }
                output.Append("\nIf you want something, holla!");
                break;

            case "OrderIntent":
                var slots = request.Intent.GetSlots();
                if (slots.Any())
                {
                    if (slots[0].Key.Equals("Number"))
                    {
                        var index = Int32.Parse(slots[0].Value) - 1;
                        output.AppendFormat("You have ordered: {0}", promotions[index]);
                    }
                    if (slots[0].Key.Equals("Item"))
                    {
                        output.AppendFormat("You have ordered: {0}. ", slots[0].Value);
                    }
                    output.Append("If you don't want that order, that's tough because you can't take it back!");
                }
                else
                {
                    output.Append("We didn't understand your order ye numpty.");
                }
                break;

            case "StopIntent":
                output.Append("Stopping");
                break;
            }
            return(new AlexaResponse(output.ToString()));
        }
示例#2
0
 private AlexaResponse SessionEndedRequestHandler(AlexaRequest.RequestAttributes request)
 {
     return(new AlexaResponse("Bye bye"));
 }
示例#3
0
 private AlexaResponse LaunchRequestHandler(AlexaRequest.RequestAttributes request)
 {
     return(new AlexaResponse("Hello would you like to hear about our promotions?"));
 }