AlexaVoxCraft.Model.Apl
2.0.0-beta.55
See the version list below for details.
dotnet add package AlexaVoxCraft.Model.Apl --version 2.0.0-beta.55
NuGet\Install-Package AlexaVoxCraft.Model.Apl -Version 2.0.0-beta.55
<PackageReference Include="AlexaVoxCraft.Model.Apl" Version="2.0.0-beta.55" />
<PackageVersion Include="AlexaVoxCraft.Model.Apl" Version="2.0.0-beta.55" />
<PackageReference Include="AlexaVoxCraft.Model.Apl" />
paket add AlexaVoxCraft.Model.Apl --version 2.0.0-beta.55
#r "nuget: AlexaVoxCraft.Model.Apl, 2.0.0-beta.55"
#addin nuget:?package=AlexaVoxCraft.Model.Apl&version=2.0.0-beta.55&prerelease
#tool nuget:?package=AlexaVoxCraft.Model.Apl&version=2.0.0-beta.55&prerelease
๐ฃ Alexa Vox Craft
Alexa Vox Craft is a modular, opinionated library for building Alexa skills in C# using .NET. It leverages System.Text.Json
, MediatR patterns, and extensible components for building and maintaining robust Alexa skills with support for:
- โ Clean separation of concerns using MediatR
- โ
JSON (de)serialization with full control via
System.Text.Json
- โ APL (Alexa Presentation Language) model support and utilities
- โ Custom converters for object, enum, and polymorphic types
- โ Lambda-ready with logging, tracing, and testability in mind
What does "AlexaVoxCraft" mean?
- Alexa: Represents the integration with Amazon Alexa, the voice service powering devices like Amazon Echo.
- VoxCraft: Signifies the focus on voice-driven interactions, leveraging the VoxCraft framework.
๐ฆ Credits:
- The core Alexa skill models (
AlexaVoxCraft.Model
) are based on the excellent work in timheuer/alexa-skills-dotnet.- APL support (
AlexaVoxCraft.Model.Apl
) is based on stoiveyp/Alexa.NET.APL.
๐๏ธ Packages
Package | Build Status | NuGet | GitHub | Downloads |
---|---|---|---|---|
AlexaVoxCraft.Model | ๐ Source | |||
AlexaVoxCraft.Model.Apl | ๐ Source | |||
AlexaVoxCraft.MediatR.Lambda | ๐ Source | |||
AlexaVoxCraft.MediatR | ๐ Source | |||
AlexaVoxCraft.Logging | ๐ Source |
๐ Project Structure
AlexaVoxCraft/
โโโ ๐ src/ # Core library packages
โ โโโ ๐ฆ AlexaVoxCraft.Model/ # Base Alexa skill models & serialization
โ โ โโโ Cards/ # Card types (Simple, Standard, LinkAccount)
โ โ โโโ Converters/ # JSON converters & polymorphic handling
โ โ โโโ Directives/ # Audio, video, dialog directives
โ โ โโโ Helpers/ # Enum utilities & response builders
โ โ โโโ Interfaces/ # Core abstractions
โ โ โโโ Request/ # Request types (Launch, Intent, Session, etc.)
โ โ โโโ Response/ # Response models & builders
โ โ โโโ Ssml/ # Complete SSML element support
โ โ โโโ UI/ # Display templates & visual cards
โ โ
โ โโโ ๐ฆ AlexaVoxCraft.Model.Apl/ # APL (Alexa Presentation Language) support
โ โ โโโ AlexaComponents/ # 40+ pre-built Alexa components
โ โ โโโ Audio/ # Audio documents & sound effects
โ โ โโโ Commands/ # 25+ APL commands (Animate, Scroll, etc.)
โ โ โโโ Components/ # Core APL components (Container, Text, etc.)
โ โ โโโ Converters/ # APL-specific JSON converters
โ โ โโโ DataSources/ # Dynamic data binding
โ โ โโโ Extensions/ # BackStack, DataStore, SmartMotion
โ โ โโโ Filters/ # Image & vector graphic filters
โ โ โโโ VectorGraphics/ # AVG (Alexa Vector Graphics) support
โ โ
โ โโโ ๐ฆ AlexaVoxCraft.MediatR/ # MediatR integration & request handling
โ โ โโโ Attributes/ # Session & persistent attributes
โ โ โโโ Behaviors/ # Pipeline behaviors & interceptors
โ โ โโโ Handlers/ # Request handler abstractions
โ โ โโโ Interfaces/ # Handler & routing interfaces
โ โ โโโ Services/ # DI registration & service discovery
โ โ
โ โโโ ๐ฆ AlexaVoxCraft.MediatR.Lambda/ # AWS Lambda hosting & runtime
โ โ โโโ Context/ # Skill context management
โ โ โโโ Extensions/ # Host builder extensions
โ โ โโโ Functions/ # Lambda function base classes
โ โ โโโ Handlers/ # Lambda-specific handlers
โ โ โโโ Serialization/ # Custom Lambda serializers
โ โ
โ โโโ ๐ฆ AlexaVoxCraft.Logging/ # Alexa-specific logging for AWS
โ โโโ Serialization/ # CloudWatch-compatible JSON formatter
โ
โโโ ๐ samples/ # Working example projects
โ โโโ ๐ฑ Sample.Skill.Function/ # Basic Alexa skill demonstration
โ โ โโโ Handlers/ # Request handlers (Launch, Intent)
โ โ โโโ Function.cs # Main Lambda function
โ โ โโโ Program.cs # Entry point
โ โ โโโ appsettings.json # Configuration
โ โ
โ โโโ ๐ฑ Sample.Apl.Function/ # APL skill with visual interfaces
โ โโโ Handlers/ # APL-enabled request handlers
โ โโโ Function.cs # APL skill function
โ โโโ Program.cs # Entry point
โ
โโโ ๐ test/ # Comprehensive test coverage
โ โโโ ๐งช AlexaVoxCraft.Model.Tests/ # Core model & serialization tests
โ โ โโโ Examples/ # 50+ JSON test files
โ โ โโโ Cards/ # Card serialization tests
โ โ โโโ Converters/ # JSON converter validation
โ โ โโโ Directives/ # Directive handling tests
โ โ โโโ Request/ # Request parsing tests
โ โ โโโ Response/ # Response building tests
โ โ โโโ Ssml/ # SSML element tests
โ โ
โ โโโ ๐งช AlexaVoxCraft.Model.Apl.Tests/ # APL functionality tests
โ โโโ Examples/ # 80+ APL JSON examples
โ โโโ AlexaComponents/ # Alexa component tests
โ โโโ Audio/ # Audio document tests
โ โโโ Commands/ # APL command tests
โ โโโ Components/ # Core component tests
โ โโโ Extensions/ # Extension tests (DataStore, etc.)
โ โโโ VectorGraphics/ # AVG parsing tests
โ
โโโ ๐ .github/ # DevOps & automation
โ โโโ workflows/ # CI/CD pipelines
โ โ โโโ build.yaml # Main build & release pipeline
โ โ โโโ pr-build.yaml # PR validation pipeline
โ โโโ dependabot.yml # Dependency management
โ
โโโ ๐ licenses/ # Third-party license files
โโโ ๐ AlexaVoxCraft.sln # Visual Studio solution
โโโ ๐ Directory.Build.props # Shared MSBuild properties
โโโ ๐ README.md # This file
โโโ ๐ LICENSE # Apache 2.0 license
โโโ ๐ NOTICE # Legal attributions
โโโ ๐ผ๏ธ icon.png # Package icon
Package Breakdown
Package | Purpose | Key Features |
---|---|---|
AlexaVoxCraft.Model | Core Alexa models | Request/response types, SSML, cards, directives, System.Text.Json serialization |
AlexaVoxCraft.Model.Apl | APL support | 40+ components, commands, audio, vector graphics, extensions (DataStore, SmartMotion) |
AlexaVoxCraft.MediatR | Request handling | Handler routing, pipeline behaviors, attributes management, DI integration |
AlexaVoxCraft.MediatR.Lambda | Lambda hosting | AWS Lambda functions, context management, custom serialization, hosting extensions |
AlexaVoxCraft.Logging | Alexa-specific logging | AWS CloudWatch-compatible JSON formatter, built on LayeredCraft.StructuredLogging |
๐ Getting Started
1. Install Required Packages
Install only the packages you need! If you're not using MediatR or APL features, you can omit those dependencies.
dotnet add package AlexaVoxCraft.Model
# Optional:
dotnet add package AlexaVoxCraft.MediatR.Lambda
2. Create a Lambda Entry Point
await LambdaHostExtensions.RunAlexaSkill<YourAlexaSkillFunction>();
3. Create Your Function Class
public sealed class YourAlexaSkillFunction : AlexaSkillFunction<SkillRequest, SkillResponse>
{
protected override void Init(IHostBuilder builder)
{
builder
.UseHandler<LambdaHandler, SkillRequest, SkillResponse>()
.ConfigureServices((context, services) =>
{
services.AddSkillMediator(context.Configuration,
cfg => { cfg.RegisterServicesFromAssemblyContaining<Program>(); });
});
}
}
4. Handle Requests with MediatR
Handlers in AlexaVoxCraft are expected to implement IRequestHandler<T>
and optionally implement ICanHandle
to provide routing logic.
public sealed class LaunchRequestHandler : IRequestHandler<LaunchRequest>
{
public bool CanHandle(IHandlerInput handlerInput) =>
handlerInput.RequestEnvelope.Request is LaunchRequest;
public async Task<SkillResponse> Handle(IHandlerInput input, CancellationToken cancellationToken = default)
{
return await input.ResponseBuilder.Speak("Hello world!").WithShouldEndSession(true)
.GetResponse(cancellationToken);
}
}
๐ Logging & Diagnostics
AlexaVoxCraft uses Serilog for structured logging by default. You can configure logging output by adding the following to your appsettings.json
:
"Serilog": {
"Using": [ "Serilog.Sinks.Console" ],
"WriteTo": [
{
"Name": "Console",
"Args": {
"formatter": "AlexaVoxCraft.Logging.Serialization.AlexaCompactJsonFormatter, AlexaVoxCraft.Logging"
}
}
],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.AspNetCore": "Warning"
}
}
}
โน๏ธ Debugging Tip: To enable logging of raw Alexa skill requests and responses during development, add the following line under
Override
. This is not recommended for production environments."AlexaVoxCraft.MediatR.Lambda.Serialization": "Debug"
๐งพ Formatter Attribution
๐ง The
AlexaCompactJsonFormatter
included in this library is adapted fromSerilog.Formatting.Compact.CompactJsonFormatter
.
This customized formatter renames reserved field names (e.g.,@t
,@l
,@m
) to AWS-safe equivalents (_t
,_l
,_m
) to improve compatibility with CloudWatch Logs and metric filters.Original work ยฉ Serilog Contributors, licensed under the MIT License.
๐งช Unit Testing
Sample projects show how to load Alexa requests from JSON and assert deserialized structure. Tests include validation of:
- Correct parsing of SkillRequest types
- APL component deserialization
- Proper usage of custom converters
๐ Utilities and Helpers
EnumHelper
: Convert to/from[EnumMember]
-decorated enumsObjectConverter
: Deserialize polymorphic object valuesBasePolymorphicConverter<T>
: Handle APL and directive subtypesAlexaLambdaSerializer
: CustomILambdaSerializer
with logging support
โ ๏ธ Error Handling
To intercept and respond to exceptions in your MediatR pipeline, implement the IExceptionHandler
interface:
public sealed class MyExceptionHandler : IExceptionHandler
{
public Task<bool> CanHandle(IHandlerInput handlerInput, Exception ex, CancellationToken cancellationToken = default)
{
return Task.FromResult(true); // Catch all
}
public Task<SkillResponse> Handle(IHandlerInput handlerInput, Exception ex, CancellationToken cancellationToken = default)
{
var response = handlerInput.ResponseBuilder.Speak("Something went wrong. Please try again.");
return response.GetResponse(cancellationToken);
}
}
No manual registration is required. Exception handlers are picked up automatically via AddSkillMediator(...)
.
๐ Sample Projects
Sample Project | Description |
---|---|
Sample.Skill.Function |
A minimal Alexa skill using this library |
Sample.Apl.Function |
A sample APL skill to demonstrate working with APL |
Each sample demonstrates MediatR integration, serialization support, custom directives, and Lambda bootstrapping.
๐คญ Roadmap
- โ Full widget lifecycle support
- โ Advanced directive handling
- โ๏ธ OpenTelemetry & logging enrichment
- ๐ Documentation site
๐ค Contributing
PRs are welcome! Please submit issues and ideas to help make this toolkit even better.
Contributors โจ
Thanks goes to these wonderful people (emoji key):
<table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/LayeredCraft"><img src="https://avatars.githubusercontent.com/u/1405469?v=4?s=100" width="100px;" alt="Nick Cipollina"/><br /><sub><b>Nick Cipollina</b></sub></a><br /><a href="#content-LayeredCraft" title="Content">๐</a></td> </tr> </tbody> </table>
This project follows the all-contributors specification. Contributions of any kind welcome!
๐ License
MIT
This project is licensed under the MIT License. See the LICENSE file for details.
Stargazers over time
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- AlexaVoxCraft.Model (>= 2.0.0-beta.55)
-
net9.0
- AlexaVoxCraft.Model (>= 2.0.0-beta.55)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
2.0.0-beta.56 | 99 | 6/23/2025 |
2.0.0-beta.55 | 103 | 6/23/2025 |
1.0.1.54 | 194 | 5/21/2025 |
1.0.1.53 | 154 | 5/19/2025 |
1.0.1.50 | 243 | 5/13/2025 |
1.0.1.49 | 224 | 5/13/2025 |
1.0.1-beta.52 | 115 | 5/19/2025 |
1.0.1-beta.48 | 198 | 5/13/2025 |
1.0.1-beta.47 | 198 | 5/13/2025 |
1.0.1-beta.46 | 196 | 5/13/2025 |
1.0.1-beta.45 | 195 | 5/13/2025 |
1.0.1-beta.44 | 195 | 5/13/2025 |
1.0.0.43 | 143 | 5/8/2025 |
1.0.0.42 | 151 | 5/7/2025 |
1.0.0.41 | 218 | 4/21/2025 |
1.0.0-beta.40 | 136 | 4/21/2025 |
0.3.0-beta-38 | 196 | 4/17/2025 |
0.3.0-beta-37 | 191 | 4/17/2025 |
0.3.0-beta-36 | 178 | 4/17/2025 |
0.3.0-beta-35 | 199 | 4/15/2025 |
0.3.0-beta-34 | 198 | 4/9/2025 |
0.3.0-beta-31 | 153 | 4/9/2025 |
0.3.0-beta-30 | 153 | 4/9/2025 |
0.3.0-beta-29 | 150 | 4/9/2025 |
0.2.0-alpha-28 | 165 | 4/9/2025 |