Skip to content

Commit

Permalink
Merge branch 'master' into playback-controller
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasxc authored Mar 14, 2017
2 parents 1b16904 + 9724020 commit 61fc4a1
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Alexa.NET/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"repository": { "url": "https://github.com/timheuer/alexa-skills-dotnet" },
"requireLicenseAcceptance": false,
"tags": [ "amazon", "alexa", "echo", "dot", "echo dot", "skills" ],
"releaseNotes": "Updated to include Locale and Audio/PlayerController request support."
"releaseNotes": "Updated to include Locale, Audio request, and PlayerController request support."
}
}
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,71 @@ var finalResponse = ResponseBuilder.TellWithCard(speech, "Your Card Title", "You
return finalResponse;

```

## Build a simple response with a reprompt
If you want to reprompt the user, use the Ask helpers
```csharp
// create the speech response
var speech = new Alexa.NET.Response.SsmlOutputSpeech();
speech.Ssml = "Today is <say-as interpret-as=\"date\">????0922</say-as>.";

// create the speech reprompt
var repromptMessage = new Alexa.NET.Response.PlainTextOutputSpeech();
repromptMessage.Text = "Would you like to know what tomorrow is?";

// create the reprompt
var repromptBody = new Alexa.NET.Response.Reprompt();
repromptBody.OutputSpeech = repromptMessage;

// create the response
var finalResponse = ResponseBuilder.Ask(speech, repromptBody);
return finalResponse;
```

## Build a response without using helpers
If you do not want to use the helper Tell/Ask functions for the simple structure you
can build up the response manually using the ```Response``` and some ```IOutputSpeech``` objects.
```csharp
// create the speech response - you most likely will still have this
var speech = new Alexa.NET.Response.SsmlOutputSpeech();
speech.Ssml = "Today is <say-as interpret-as=\"date\">????0922</say-as>.";

// create the response
var responseBody = new Alexa.NET.Response.ResponseBody();
responseBody.OutputSpeech = speech;
responseBody.ShouldEndSession = true;

var skillResponse = new Alexa.NET.Response.SkillResponse();
skillResponse.Response = responseBody;
skillResponse.Version = "1.0";

return skillResponse;
```

## Build a reprompt without using helpers
To add reprompt to the response you just need to include that as well.
```csharp
// create the speech response - you most likely will still have this
var speech = new Alexa.NET.Response.SsmlOutputSpeech();
speech.Ssml = "Today is <say-as interpret-as=\"date\">????0922</say-as>.";

// create the reprompt speech
var repromptMessage = new Alexa.NET.Response.PlainTextOutputSpeech();
repromptMessage.Text = "Would you like to know what tomorrow is?";

// create the reprompt object
var repromptBody = new Alexa.NET.Response.Reprompt();
repromptBody.OutputSpeech = repromptMessage;

// create the response
var responseBody = new Alexa.NET.Response.ResponseBody();
responseBody.OutputSpeech = speech;
responseBody.ShouldEndSession = false; // this triggers the reprompt
responseBody.Reprompt = repromptBody;

var skillResponse = new Alexa.NET.Response.SkillResponse();
skillResponse.Response = responseBody;
skillResponse.Version = "1.0";

return skillResponse;
```

0 comments on commit 61fc4a1

Please sign in to comment.