Alexa.NET.APL 3.11.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Alexa.NET.APL --version 3.11.0
NuGet\Install-Package Alexa.NET.APL -Version 3.11.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Alexa.NET.APL" Version="3.11.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Alexa.NET.APL --version 3.11.0
#r "nuget: Alexa.NET.APL, 3.11.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Alexa.NET.APL as a Cake Addin
#addin nuget:?package=Alexa.NET.APL&version=3.11.0

// Install Alexa.NET.APL as a Cake Tool
#tool nuget:?package=Alexa.NET.APL&version=3.11.0

Alexa.NET.APL

Small helper library to allow Alexa.NET skills to work with APL

Access to APL ViewPort Data within your skill

There are new Display and Viewport properties available within the request being sent to an APL enabled skill. Rather than create a forced dependency for Alexa.NET - APL skills have an enhanced SkillRequest object with these new properties Amazon information on Viewport information: https://developer.amazon.com/docs/alexa-presentation-language/apl-viewport-characteristics.html Here's an example signature and opening line for a lambda function

public Task<SkillResponse> FunctionHandler(APLSkillRequest input, ILambdaContext context)
var shape = input.Context.Viewport?.Shape;

Creating a Layout Document

Alexa.NET.APL has a set of APL components so that creating layouts is entirely within the C# object model All properties are of Type APLValue&lt;T&gt; - which allows you to specify an absolute value or an APL data binding expression for each property

new Layout(new[]
{
  new Container(
    new APLComponent[]{
      new Text("APL in C#"){FontSize = "24dp",TextAlign= "Center"},
      new Image("https://example.com/image.jpg"){Width = 400,Height=400}
    })
  }){Direction = "row"}
})

Alexa.NET.APL has support for the custom Layouts provided by the Alexa team. These need to be imported into a document before the layout can be used inside a document.

var document = new APLDocument();
AlexaFooter.ImportInto(document);

document.MainTemplate = new Layout(
    new AlexaFooter("Hint Text")
).AsMain();

Sending a RenderDocument Directove

RenderDocument hooks into the same Alexa.NET directive mechanism that already exists, you just reference the layout, document token and any data sources you want to send along with it

            var shape = input.Context.Viewport?.Shape;
            var response = ResponseBuilder.Tell($"Your viewport is {shape.ToString() ?? "Non existent"}");

            var directive = new RenderDocumentDirective
            {
                Token = "randomToken",
                Document = new APLDocument
                {
                    MainTemplate = new Layout(new[]
                    {
                        new Container(new APLComponent[]{
                            new Text("APL in C#"){FontSize = "24dp",TextAlign= "Center"},
                            new Image("https://images.example.com/photos/2143/lights-party-dancing-music.jpg?cs=srgb&dl=cheerful-club-concert-2143.jpg&fm=jpg"){Width = 400,Height=400}
                        }){Direction = "row"}
                    })
                }
            };

            response.Response.Directives.Add(directive);

Receiving SendEvent Commands from your layout

Commands are supported within Alexa.NET.APL - to send events back from your layout to your skill you need the SendEvent Command:

https://developer.amazon.com/docs/alexa-presentation-language/apl-standard-commands.html#sendevent-command

var wrapper = new TouchWrapper
{
   OnPress = new SendEvent
   {
     Arguments = new Dictionary<string, object> {{"sent", true}}
   }
};

To receive these events you need to add support for the UserEventRequest, which can be placed in your Lambda constructor

new UserEventRequestHandler().AddToRequestConverter();

and then you treat them like any other request type, for example

if (input.Request is UserEventRequest userEvent)
{
    var token = userEvent.Token;
    var argument = userEvent.Arguments["sent"];
}

Obviously your user may interact with your skill through voice means, at which point you need to be able to send commands down to your layout. This is done with the ExecuteCommands directive

using Alexa.NET.APL.Commands;
...
var sendEvent = new ExecuteCommandsDirective("token",new []
{
    new SetPage
    {
        ComponentId="exampleId",
        Value=3
    }
});
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.6 is compatible.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Alexa.NET.APL:

Package Downloads
Ask.Sdk.Core

Core SDK package that contains the basic components and default implementations of ASK SDK for .Net Core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.3.0 1,797 1/14/2024
8.2.0 1,340 8/24/2023
8.1.0 1,950 5/29/2023
8.0.0 155 5/27/2023
7.6.3 2,112 2/8/2023
7.6.2 1,751 10/22/2022
7.6.1 770 8/15/2022
7.6.0 4,409 6/9/2022
7.5.0 1,813 12/16/2021
7.4.0 1,370 10/1/2021
7.3.0 1,045 7/21/2021
7.2.0 17,274 4/3/2021
7.1.0 676 2/17/2021
7.0.0 5,531 11/20/2020
6.1.0 1,144 9/26/2020
6.0.4 1,484 7/24/2020
6.0.3 553 7/23/2020
6.0.2 562 7/23/2020
5.1.1 3,056 3/31/2020
5.1.0 545 3/26/2020
5.0.0 564 3/26/2020
4.9.1 522 3/17/2020
4.9.0 773 1/6/2020
4.8.1 555 12/19/2019
4.8.0 580 12/5/2019
4.7.0 635 11/26/2019
4.6.0 919 11/7/2019
4.5.1 599 11/1/2019
4.4.2 575 10/30/2019
4.4.1 565 10/30/2019
4.4.0 565 10/25/2019
4.3.1 533 10/24/2019
4.3.0 554 10/24/2019
4.2.3 639 9/10/2019
4.2.1 550 9/10/2019
4.2.0 2,860 8/9/2019
4.1.2 624 8/8/2019
4.1.1 629 8/8/2019
4.1.0 666 8/7/2019
4.0.13 713 7/28/2019
4.0.12 646 7/28/2019
4.0.11 700 7/15/2019
4.0.10 666 7/14/2019
4.0.9 614 7/14/2019
4.0.8 618 7/14/2019
4.0.7 678 7/14/2019
4.0.6 681 7/11/2019
4.0.5 674 7/10/2019
4.0.4 669 7/10/2019
4.0.2 667 7/10/2019
4.0.1 682 7/7/2019
4.0.0 619 7/6/2019
3.15.0 701 5/15/2019
3.14.0 679 5/9/2019
3.13.0 658 5/5/2019
3.12.0 659 5/4/2019
3.11.0 1,123 3/27/2019
3.10.0 644 3/27/2019
3.9.0 622 3/18/2019
3.8.0 737 3/4/2019
3.7.0 681 3/3/2019
3.6.3 766 1/31/2019
3.6.2 799 1/23/2019
3.6.1 1,364 1/14/2019
3.5.0 791 1/14/2019
3.4.0 818 1/9/2019
3.3.0 762 1/9/2019
3.1.0 790 12/26/2018
3.0.0 715 12/25/2018
2.1.0 733 12/25/2018
2.0.0 858 12/13/2018
1.6.4 770 12/7/2018
1.6.3 1,074 11/11/2018
1.6.1 843 11/11/2018
1.6.0 756 11/11/2018
1.5.0 835 11/6/2018
1.4.3 816 11/6/2018
1.4.2 775 11/6/2018
1.4.1 768 11/6/2018
1.4.0 785 11/5/2018
1.3.2 840 11/5/2018
1.2.2 807 11/5/2018
1.2.1 847 11/5/2018
1.2.0 810 11/5/2018
1.1.0 807 11/4/2018
1.0.0 746 11/2/2018

Fix Pager data property