public void DirectiveResponse() { AlexaResponse resp = new AlexaResponse { Version = "1.0", Response = new AlexaResponseAttributes { OutputSpeech = OutputSpeechBuilder.GetPlainTextSpeech("You are hearing me talk."), Card = CardBuilder.GetSimpleCardResponse("Card Title", "This is some card text."), }, }; DisplayDirectiveResponse displayResp = new DisplayDirectiveResponse(); displayResp.Template = new DisplayTemplate(); displayResp.Template.Type = DisplayTemplateTypeEnum.BodyTemplate3; displayResp.Template.Token = "user_email"; displayResp.Template.Title = "Display Title"; displayResp.Template.TextContent = new DisplayTextContent(); displayResp.Template.TextContent.PrimaryText = new DisplayTextField(); displayResp.Template.TextContent.PrimaryText.Type = DisplayTextTypeEnum.RichText; displayResp.Template.TextContent.PrimaryText.Text = "<b><font size=\"6\">Some bold text</font></b>"; displayResp.Template.Image = new DisplayDirectiveImage("small image", "http://pathtosomeimage"); displayResp.Template.BackgroundImage = new DisplayDirectiveImage("background image", "http://pathtosomebackgroundimage"); resp.Response.Directives = new List <DirectiveResponse>(); resp.Response.Directives.Add(displayResp); string textResp = JsonConvert.SerializeObject(resp, Formatting.Indented); // The text should serialize to empty brackets. }
private async Task <AlexaResponse> GetLaunchResponseAsync(AlexaRequest request) { Adventure adv = await _adventureRep.GetAdventureAsync(); AdventureNode curNode = await _curNodeRep.GetCurrentNodeAsync(request, adv.Nodes); // If there is a current node that has choices, then let the user resume. bool nodeHasChoices = (curNode?.NodeRoutes?.Any()).GetValueOrDefault(false); AlexaResponse resp; if (!nodeHasChoices) { string welcomeText = "Welcome to the Adventure Sample. When you are ready to start the adventure, say begin"; resp = new AlexaResponse { Version = "1.0", Response = new AlexaResponseAttributes { OutputSpeech = OutputSpeechBuilder.GetPlainTextSpeech(welcomeText), Card = CardBuilder.GetSimpleCardResponse("Welcome to the Adventure", welcomeText), Reprompt = new RepromptAttributes { OutputSpeech = OutputSpeechBuilder.GetPlainTextSpeech("Say begin when you're ready to begin") } } }; } else { string resumeText = "Welcome back! You have an adventure in progress. Would you like to resume or restart?"; resp = new AlexaResponse { Version = "1.0", Response = new AlexaResponseAttributes { OutputSpeech = OutputSpeechBuilder.GetPlainTextSpeech(resumeText), Card = CardBuilder.GetSimpleCardResponse("Welcome Back to the Adventure", resumeText), Reprompt = new RepromptAttributes { OutputSpeech = OutputSpeechBuilder.GetPlainTextSpeech("You can resume or restart.") } } }; } return(resp); }
public void SimpleResponse() { string textResp = "You are following a path in forest and have come to a fork. Would you like to go left or right?"; StringBuilder ssmlSample = new StringBuilder(); ssmlSample.Append("<speak><audio src='https://dev-sbsstoryengine.s3.amazonaws.com/stories/animalfarmpi/audio/Act1-OpeningMusic-alexa.mp3'/> "); ssmlSample.Append("It was a dark and stormy night. <break time='500ms'/>"); ssmlSample.Append("<say-as interpret-as='interjection'>no way!</say-as> "); ssmlSample.Append("I'm not doing this. That doesn’t make any sense! That music didn’t sound dark and stormy at "); ssmlSample.Append("<prosody volume='x-loud' pitch='+10%'>all!</prosody>"); ssmlSample.Append(" It sounds to me more like a bright and chipper morning! Should we go with dark and stormy, or bright and chipper?"); ssmlSample.Append("</speak>"); StringBuilder librarySample = new StringBuilder(); librarySample.Append("<speak>"); librarySample.Append(Office.ELEVATOR_BELL_1X_01); librarySample.Append("Your hotel is booked!"); librarySample.Append("</speak>"); AlexaResponse resp = new AlexaResponse { Version = "1.0", Response = new AlexaResponseAttributes { // OutputSpeech = OutputSpeechBuilder.GetPlainTextSpeech(textResp), OutputSpeech = OutputSpeechBuilder.GetSsmlSpeech(ssmlSample.ToString()), Card = CardBuilder.GetStandardCardResponse("Fork in the Road", textResp, "https://dev-custom.s3.amazonaws.com/adventuregame/images/forkintheroad_1200x600.png", "https://dev-custom.s3.amazonaws.com/adventuregame/images/forkintheroad_1200x600.png" ), Reprompt = new RepromptAttributes { OutputSpeech = OutputSpeechBuilder.GetPlainTextSpeech("Left or right?"), }, ShouldEndSession = false }, }; string textSer = JsonConvert.SerializeObject(resp, Formatting.Indented); // The text should serialize to empty brackets. }