Skip to content

Commit

Permalink
Added
Browse files Browse the repository at this point in the history
- built-in intents (helpful for audio player skills)
- audio player request types
- enqueued token property into the AudioPlayerRequest
- ClearQueue directive and enums
  • Loading branch information
matthiasxc committed Mar 8, 2017
1 parent 323bde8 commit a8114ab
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 2 deletions.
36 changes: 36 additions & 0 deletions Alexa.NET/Request/Type/AudioPlayerRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,41 @@ public class AudioPlayerRequest: Request

[JsonProperty("currentPlaybackState")]
public PlaybackState CurrentPlaybackState { get; set; }

[JsonProperty("enqueuedToken")]
public string EnqueuedToken { get; set; }

public bool HasEnqueuedItem
{
get
{
if (EnqueuedToken != null && EnqueuedToken != "")
return true;
else
return false;
}
}

public AudioRequestType AudioRequestType
{
get
{
switch (this.Type.Split('.')[1])
{
case "PlaybackStarted":
return AudioRequestType.PlaybackStarted;
case "PlaybackFinished":
return AudioRequestType.PlaybackStarted;
case "PlaybackStopped":
return AudioRequestType.PlaybackStopped;
case "PlaybackNearlyFinished":
return AudioRequestType.PlaybackNearlyFinished;
case "PlaybackFailed":
return AudioRequestType.PlaybackFailed;
default:
return AudioRequestType.Unknown;
}
}
}
}
}
24 changes: 24 additions & 0 deletions Alexa.NET/Request/Type/AudioRequestType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading.Tasks;

namespace Alexa.NET.Request.Type
{
public enum AudioRequestType
{
[EnumMember(Value = "PlaybackStarted")]
PlaybackStarted,
[EnumMember(Value = "PlaybackFinished")]
PlaybackFinished,
[EnumMember(Value = "PlaybackStopped")]
PlaybackStopped,
[EnumMember(Value = "PlaybackNearlyFinished")]
PlaybackNearlyFinished,
[EnumMember(Value = "PlaybackFailed")]
PlaybackFailed,
[EnumMember(Value = "Unknown")]
Unknown
}
}
137 changes: 137 additions & 0 deletions Alexa.NET/Request/Type/BuiltInIntents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Alexa.NET.Request.Type
{
/// <summary>
/// Standard Built-In Intents detailed here:
/// https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/standard-intents
/// </summary>

public class BuiltInIntent
{

/// <summary>
/// Purpose:
/// - Let the user cancel a transaction or task (but remain in the skill)
/// - Let the user completely exit the skill
///
/// Common Utterances: cancel, never mind, forget it
/// </summary>
public const string Cancel = "AMAZON.CancelIntent";

/// <summary>
/// Purpose:
/// Provide help about how to use the skill.
///
/// Common Utterances: help, help me, can you help me
/// </summary>
public const string Help = "AMAZON.HelpIntent";

/// <summary>
/// Purpose:
/// - Let the user stop an action (but remain in the skill)
/// - Let the user completely exit the skill
///
/// Common Utterances: stop, off, shut up
/// </summary>
public const string Stop = "AMAZON.StopIntent";

public const string Yes = "AMAZON.YesIntent";

public const string No = "AMAZON.NoIntent";

/// <summary>
/// Audio Intents
/// - These intents are for use with a skill that plays audio
/// </summary>
///

/// <summary>
/// Purpose:
/// - Lets user turn on or off an audio loop
/// - can be used without the skill invocation name (ie: "Alexa, loop on")
///
/// Common Utterances: loop off, loop on
/// </summary>
public const string LoopOff = "AMAZON.LoopOffIntent";

public const string LoopOn = "AMAZON.LoopOnIntent";

/// <summary>
/// Purpose:
/// - Lets user turn on or off shuffle mode, usually for audio skills that
/// stream a playlist of tracks
/// - can be used without the skill invocation name (ie: "Alexa, loop on")
///
/// Common Utterances: loop off, loop on
/// </summary>
public const string ShuffleOn = "AMAZON.ShuffleOnIntent";

public const string ShuffleOff = "AMAZON.ShuffleOffIntent";

/// <summary>
/// Purpose:
/// - Let the user navigate to the next item in a list
/// - typically used for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, next")
///
/// Common Utterances: next, skip, skip forward
/// </summary>
public const string Next = "AMAZON.NextIntent";

/// <summary>
/// Purpose:
/// - Let the user navigate to the previous item in a list
/// - typically used for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, go back")
///
/// Common Utterances: go back, skip back, back up
/// </summary>
public const string Previous = "AMAZON.PreviousIntent";

/// <summary>
/// Purpose:
/// - Let the user pause the action in progress (such as a game or audio track)
/// - MUST be implemented for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, pause")
///
/// Common Utterances: pause, pause that
/// </summary>
public const string Pause = "AMAZON.PauseIntent";

/// <summary>
/// Purpose:
/// - Let the user navigate repeat the last action
/// - can be used without the skill invocation name (ie: "Alexa, repeat")
///
/// Common Utterances: repeat, say that again
/// </summary>
public const string Repeat = "AMAZON.RepeatIntent";

/// <summary>
/// Purpose:
/// - Let the user resume or continue an action
/// - MUST be implemented for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, resume ")
///
/// Common Utterances: resume, continue, keep going
/// </summary>
public const string Resume = "AMAZON.ResumeIntent";

/// <summary>
/// Purpose:
/// - Let the user to restart an action, such as restarting a game,
/// transaction, or audio track.
/// - typically used for skills that stream audio
/// - can be used without the skill invocation name (ie: "Alexa, restart")
///
/// Common Utterances: start over, restart, start again
/// </summary>
public const string StartOver = "AMAZON.StartOverIntent";

}

}
3 changes: 3 additions & 0 deletions Alexa.NET/Request/Type/RequestConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public override object ReadJson(JsonReader reader, System.Type objectType, objec

public Request Create(string requestType)
{
//Note: could add a System.ExceptionEncountered request type
// Also might be valuable to add built-in requests (which start with "AMAZON.")

//AudioPlayer requests are very similar, map to single type
if (requestType.StartsWith("AudioPlayer"))
requestType = "AudioPlayer";
Expand Down
16 changes: 16 additions & 0 deletions Alexa.NET/Response/Directive/ClearBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading.Tasks;

namespace Alexa.NET.Response.Directive
{
public enum ClearBehavior
{
[EnumMember(Value = "CLEAR_ENQUEUED")]
ClearEnqueued,
[EnumMember(Value = "CLEAR_ALL")]
ClearAll,
}
}
20 changes: 20 additions & 0 deletions Alexa.NET/Response/Directive/ClearQueueDirective.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Alexa.NET.Response.Directive
{
public class ClearQueueDirective : IDirective
{
[JsonProperty("type")]
public string Type => "AudioPlayer.ClearQueue";

[JsonProperty("clearBehavior")]
[JsonRequired]
[JsonConverter(typeof(StringEnumConverter))]
public PlayBehavior ClearBehavior { get; set; }
}
}
14 changes: 12 additions & 2 deletions Alexa.NET/ResponseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,22 @@ public static SkillResponse Tell(IOutputSpeech speechResponse)
{
return BuildResponse(speechResponse, true, null, null, null);
}
public static SkillResponse TellWithReprompt(IOutputSpeech speechResponse, Reprompt reprompt)
{
return BuildResponse(speechResponse, true, null, reprompt, null);
}


public static SkillResponse Tell(IOutputSpeech speechResponse, Session sessionAttributes)
{
return BuildResponse(speechResponse, true, sessionAttributes, null, null);
}

}

public static SkillResponse TellWithReprompt(IOutputSpeech speechResponse, Reprompt reprompt, Session sessionAttributes)
{
return BuildResponse(speechResponse, true, sessionAttributes, reprompt, null);
}

public static SkillResponse TellWithCard(IOutputSpeech speechResponse, string title, string content)
{
SimpleCard card = new SimpleCard();
Expand Down

0 comments on commit a8114ab

Please sign in to comment.